Skip to content

Commit

Permalink
Add tests verifying NODE KEY works in grammar
Browse files Browse the repository at this point in the history
  • Loading branch information
Mats-SX committed May 4, 2017
1 parent 4d66f6b commit 16c2843
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 13 deletions.
2 changes: 2 additions & 0 deletions grammar/basic-grammar.xml
Original file line number Diff line number Diff line change
Expand Up @@ -666,6 +666,8 @@
ALL
NONE
SINGLE
NODE
KEY
</alt>
</production>

Expand Down
15 changes: 8 additions & 7 deletions grammar/commands.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
<!-- / NEW CONSTRAINT SYNTAX \ -->

<production name="CreateConstraint">
CREATE &SP; CONSTRAINT &SP; <non-terminal ref="ConstraintName"/> &SP;
ADD &SP; CONSTRAINT &SP; <non-terminal ref="ConstraintName"/> &SP;
FOR &SP; <non-terminal ref="ConstraintPattern"/> &SP;
REQUIRE &SP; <non-terminal ref="ConstraintExpression"/>
</production>
Expand All @@ -75,17 +75,18 @@

<production name="ConstraintExpression">
<alt>
<non-terminal ref="NodePropertyUniquenessConstraint"/>
<non-terminal ref="PropertyExistenceConstraint"/>
<non-terminal ref="Uniqueness"/>
<non-terminal ref="NodeKey"/>
<non-terminal ref="Expression"/>
</alt>
</production>

<production name="NodePropertyUniquenessConstraint">
UNIQUE &SP; <non-terminal ref="PropertyExpression"/> <repeat>&WS; , &WS; <non-terminal ref="PropertyExpression"/></repeat>
<production name="Uniqueness">
UNIQUE &SP; <non-terminal ref="PropertyExpression"/>
</production>

<production name="PropertyExistenceConstraint">
exists ( <non-terminal ref="PropertyExpression"/> )
<production name="NodeKey">
NODE &SP; KEY &SP; <non-terminal ref="PropertyExpression"/> <repeat>&WS; , &WS; <non-terminal ref="PropertyExpression"/></repeat>
</production>

<!-- / LEGACY COMMANDS \ -->
Expand Down
18 changes: 12 additions & 6 deletions tools/grammar/src/test/resources/cypher.txt
Original file line number Diff line number Diff line change
Expand Up @@ -267,16 +267,22 @@ MATCH (a) CALL proc( )§
MATCH (a) CALL proc( a, b , c )§
MATCH (a) CALL proc( a, b , c ) YIELD a, b , c§
CALL proc( ) RETURN *§
CREATE CONSTRAINT foo
ADD CONSTRAINT foo
FOR (p:Person)
REQUIRE UNIQUE p.name§
CREATE CONSTRAINT bar
FOR (p:Person)
REQUIRE UNIQUE p.name, p.email§
CREATE CONSTRAINT baz
ADD CONSTRAINT baz
FOR (p:Person)
REQUIRE exists(p.name)§
CREATE CONSTRAINT cru
ADD CONSTRAINT cru
FOR ()-[r:REL]-()
REQUIRE exists(r.property)§
DROP CONSTRAINT foo_bar_baz§
ADD CONSTRAINT nodeKey
FOR (n:Node)
REQUIRE NODE KEY n.prop§
ADD CONSTRAINT nodeKey
FOR (n:Node)
REQUIRE NODE KEY n.p1, n.p2, n.p3§
ADD CONSTRAINT nodeKey
FOR (n:Node)
REQUIRE NODE KEY n.p1 ,n.p2, n.p3§

0 comments on commit 16c2843

Please sign in to comment.