From 1fd0cbf61be7da54649e853c4eb4162ec27498eb Mon Sep 17 00:00:00 2001 From: Mats Rydberg Date: Thu, 15 Dec 2016 12:23:50 +0100 Subject: [PATCH] Add grammar rules for new constraint syntax --- grammar/basic-grammar.xml | 2 +- grammar/commands.xml | 45 ++++++++++++++++++++- tools/grammar/src/test/resources/cypher.txt | 13 ++++++ 3 files changed, 57 insertions(+), 3 deletions(-) diff --git a/grammar/basic-grammar.xml b/grammar/basic-grammar.xml index dbdd58f799..decbaddd0c 100644 --- a/grammar/basic-grammar.xml +++ b/grammar/basic-grammar.xml @@ -134,7 +134,7 @@ - + : diff --git a/grammar/commands.xml b/grammar/commands.xml index 7b8161fa68..42b331fb0a 100644 --- a/grammar/commands.xml +++ b/grammar/commands.xml @@ -31,7 +31,7 @@ xmlns:rr="http://opencypher.org/railroad" xmlns:oc="http://opencypher.org/opencypher"> - + @@ -44,10 +44,51 @@ + + + + + + + + + + CREATE &SP; CONSTRAINT &SP; &SP; + FOR &SP; &SP; + REQUIRE &SP; + + + + DROP &SP; CONSTRAINT &SP; + + + + + + + + + ( &var; &label; ) + ( ) - [ &var; ] - ( ) + + + + + + + - + + UNIQUE &SP; &WS; , &WS; + + + + exists ( ) + + + CREATE &SP; diff --git a/tools/grammar/src/test/resources/cypher.txt b/tools/grammar/src/test/resources/cypher.txt index bf6af6b0f2..675c9ef4cc 100644 --- a/tools/grammar/src/test/resources/cypher.txt +++ b/tools/grammar/src/test/resources/cypher.txt @@ -178,3 +178,16 @@ RETURN .0020123§ RETURN 10101.0020123§ RETURN 10101.4§ RETURN 99882.04000§ +CREATE CONSTRAINT foo +FOR (p:Person) +REQUIRE UNIQUE p.name§ +CREATE CONSTRAINT bar +FOR (p:Person) +REQUIRE UNIQUE p.name, p.email§ +CREATE CONSTRAINT baz +FOR (p:Person) +REQUIRE exists(p.name)§ +CREATE CONSTRAINT cru +FOR ()-[r:REL]-() +REQUIRE exists(r.property)§ +DROP CONSTRAINT foo_bar_baz§