Throw exception on trailing text in query

Reviewers: buda

Reviewed By: buda

Subscribers: pullbot

Differential Revision: https://phabricator.memgraph.io/D222
This commit is contained in:
Mislav Bradac 2017-04-04 18:30:10 +02:00
parent 13aafa35cf
commit 6112454b08
2 changed files with 5 additions and 1 deletions

View File

@ -16,7 +16,7 @@
*/ */
grammar Cypher; grammar Cypher;
cypher : SP? statement ( SP? ';' )? SP? ; cypher : SP? statement ( SP? ';' )? SP? EOF ;
statement : query ; statement : query ;

View File

@ -47,6 +47,10 @@ TEST(CypherMainVisitorTest, SyntaxException) {
ASSERT_THROW(AstGenerator("CREATE ()-[*1...2]-()"), SyntaxException); ASSERT_THROW(AstGenerator("CREATE ()-[*1...2]-()"), SyntaxException);
} }
TEST(CypherMainVisitorTest, SyntaxExceptionOnTrailingText) {
ASSERT_THROW(AstGenerator("RETURN 2 + 2 mirko"), SyntaxException);
}
TEST(CypherMainVisitorTest, PropertyLookup) { TEST(CypherMainVisitorTest, PropertyLookup) {
AstGenerator ast_generator("RETURN n.x"); AstGenerator ast_generator("RETURN n.x");
auto *query = ast_generator.query_; auto *query = ast_generator.query_;