Fix semicolon in column name
Summary: Special casing the last token when adding it to the named expression list. Added a test to check this case. Reviewers: mislav.bradac Reviewed By: mislav.bradac Subscribers: pullbot Differential Revision: https://phabricator.memgraph.io/D1052
This commit is contained in:
parent
a8488ac497
commit
2758b35c08
@ -181,7 +181,7 @@ StrippedQuery::StrippedQuery(const std::string &query) : original_(query) {
|
||||
jt != tokens.end() && (jt->second != "," || num_open_braces ||
|
||||
num_open_parantheses || num_open_brackets) &&
|
||||
jt->second != "order" && jt->second != "skip" &&
|
||||
jt->second != "limit" && jt->second != "union";
|
||||
jt->second != "limit" && jt->second != "union" && jt->second != ";";
|
||||
++jt) {
|
||||
if (jt->second == "(") {
|
||||
++num_open_parantheses;
|
||||
|
@ -346,4 +346,15 @@ TEST(QueryStripper, QueryReturnMap) {
|
||||
EXPECT_THAT(stripped.named_expressions(),
|
||||
UnorderedElementsAre(Pair(2, "{a: 1, b: 'foo'}")));
|
||||
}
|
||||
|
||||
TEST(QueryStripper, QuerySemicolonEndingQuery1) {
|
||||
StrippedQuery stripped("RETURN 1;");
|
||||
EXPECT_THAT(stripped.named_expressions(), UnorderedElementsAre(Pair(2, "1")));
|
||||
}
|
||||
|
||||
TEST(QueryStripper, QuerySemicolonEndingQuery2) {
|
||||
StrippedQuery stripped("RETURN 42 ;");
|
||||
EXPECT_THAT(stripped.named_expressions(),
|
||||
UnorderedElementsAre(Pair(2, "42")));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user