Skip to content

Commit

Permalink
Support arbitrary patterns
Browse files Browse the repository at this point in the history
- Remove TODO
- Add example using larger pattern
- Add example using multiple `exists()`
  • Loading branch information
Mats-SX committed Mar 6, 2017
1 parent 49f8b2e commit 09f003a
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions cip/1.accepted/CIP2016-12-14-Constraint-syntax.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,8 @@ The constraint syntax is defined as follows:
[source, ebnf]
----
constraint command = create-constraint | drop-constraint ;
create-constraint = "CREATE", "CONSTRAINT", constraint-name, "FOR", constraint-pattern, "REQUIRE", constraint-expr, { "REQUIRE", constraint-expr } ;
create-constraint = "CREATE", "CONSTRAINT", constraint-name, "FOR", pattern, "REQUIRE", constraint-expr, { "REQUIRE", constraint-expr } ;
constraint-name = symbolic-name
constraint-pattern = node-pattern | simple-pattern ;
constraint-expr = uniqueness-expr | expression ;
uniquness-expr = "UNIQUE", property-expression, { ",", property-expression }
drop-constraint = "DROP", "CONSTRAINT", constraint-name ;
Expand All @@ -51,8 +50,6 @@ To that set of valid expressions, this CIP further specifies a special prefix op
All constraints require the user to specify a nonempty _name_ at constraint creation time.
This name is subsequently the handle with which a user may refer to the constraint, for example when dropping it.

// TODO: Should we impose restrictions on the domain of constraint names, or are all Unicode characters allowed?

==== Removing constraints

A constraint is removed by referring to its name.
Expand Down Expand Up @@ -185,6 +182,22 @@ This composite constraint will make sure that all `:Color` nodes has a value for

More complex constraint definitions are considered below:

.Multiple property existence using conjunction
[source, cypher]
----
CREATE CONSTRAINT person_properties
FOR (p:Person)
REQUIRE exists(p.name) AND exists(p.email)
----

.Using larger pattern
[source, cypher]
----
CREATE CONSTRAINT not_rating_own_posts
FOR (u1:User)-[:RATED]->(:Post)<-[:POSTED_BY]-(u2:User)
REQUIRE u.name <> u2.name
----

.Property value limitations
[source, cypher]
----
Expand Down

0 comments on commit 09f003a

Please sign in to comment.