mirror of
https://github.com/dragonflydb/dragonfly.git
synced 2024-12-14 11:58:02 +00:00
fix: fix parsing nested arrays (#1189)
Signed-off-by: Andrew Dunstall <andydunstall@hotmail.co.uk>
This commit is contained in:
parent
dc853fe4bd
commit
79da3e6637
2 changed files with 15 additions and 3 deletions
|
@ -276,9 +276,6 @@ auto RedisParser::ConsumeArrayLen(Buffer str) -> Result {
|
|||
return OK;
|
||||
}
|
||||
|
||||
DVLOG(1) << "PushStack: (" << len << ", " << cached_expr_ << ")";
|
||||
parse_stack_.emplace_back(len, cached_expr_);
|
||||
|
||||
if (state_ == PARSE_ARG_S) {
|
||||
DCHECK(!server_mode_);
|
||||
|
||||
|
@ -292,6 +289,9 @@ auto RedisParser::ConsumeArrayLen(Buffer str) -> Result {
|
|||
state_ = PARSE_ARG_S;
|
||||
}
|
||||
|
||||
DVLOG(1) << "PushStack: (" << len << ", " << cached_expr_ << ")";
|
||||
parse_stack_.emplace_back(len, cached_expr_);
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -197,4 +197,16 @@ TEST_F(RedisParserTest, NILs) {
|
|||
ASSERT_EQ(RedisParser::OK, Parse("_\r\n"));
|
||||
}
|
||||
|
||||
TEST_F(RedisParserTest, NestedArray) {
|
||||
parser_.SetClientMode();
|
||||
|
||||
// [[['foo'],['bar']],['car']]
|
||||
ASSERT_EQ(RedisParser::OK,
|
||||
Parse("*2\r\n*2\r\n*1\r\n$3\r\nfoo\r\n*1\r\n$3\r\nbar\r\n*1\r\n$3\r\ncar\r\n"));
|
||||
|
||||
ASSERT_THAT(args_, ElementsAre(ArrArg(2), ArrArg(1)));
|
||||
ASSERT_THAT(args_[0].GetVec(), ElementsAre(ArrArg(1), ArrArg(1)));
|
||||
ASSERT_THAT(args_[1].GetVec(), ElementsAre("car"));
|
||||
}
|
||||
|
||||
} // namespace facade
|
||||
|
|
Loading…
Reference in a new issue