-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Deprecate legacy pattern syntax #9160
Conversation
28662c1
to
bbb2831
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like to see a number of acceptance tests for this.
| EMPTY ~ push(Seq()) | ||
private def RelationshipTypes: Rule1[MaybeLegacyRelTypes] = rule("relationship types") ( | ||
(":" ~~ RelTypeName ~~ zeroOrMore(WS ~ "|" ~~ LegacyCompatibleRelTypeName)) ~~>> ( | ||
(first: ast.RelTypeName, more:List[(Boolean,ast.RelTypeName)]) => (pos:InputPosition) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code style: space after type-spec colon, space after comma.
) | ||
|
||
private def LegacyCompatibleRelTypeName: Rule1[(Boolean,ast.RelTypeName)] = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
code style: space after comma.
) | ||
|
||
private def LegacyCompatibleRelTypeName: Rule1[(Boolean,ast.RelTypeName)] = | ||
((":" ~ push(true)) | EMPTY ~ push(false)) ~~ RelTypeName ~~>> ( | ||
(legacy:Boolean, name:ast.RelTypeName) => (pos:InputPosition) => (legacy,name)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code style: space after colon and comma.
@@ -122,3 +129,5 @@ trait Patterns extends Parser | |||
optional(WS ~ (MapLiteral | Parameter)) | |||
) | |||
} | |||
|
|||
case class MaybeLegacyRelTypes(types:Seq[ast.RelTypeName] = Seq.empty, legacySeparator:Boolean = false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
code style: space after colon.
@@ -35,6 +35,10 @@ object SyntaxDeprecationWarnings extends VisitorPhase[BaseContext, BaseState] { | |||
statement.treeFold(Set.empty[InternalNotification]) { | |||
case f@FunctionInvocation(_, FunctionName(name), _, _) if aliases.get(name).nonEmpty => | |||
(seq) => (seq + DeprecatedFunctionNotification(f.position, name, aliases(name)), None) | |||
case p@RelationshipPattern(Some(variable),_,Some(_),_, _, _) => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
code style: space after comma.
@@ -35,6 +35,10 @@ object SyntaxDeprecationWarnings extends VisitorPhase[BaseContext, BaseState] { | |||
statement.treeFold(Set.empty[InternalNotification]) { | |||
case f@FunctionInvocation(_, FunctionName(name), _, _) if aliases.get(name).nonEmpty => | |||
(seq) => (seq + DeprecatedFunctionNotification(f.position, name, aliases(name)), None) | |||
case p@RelationshipPattern(Some(variable),_,Some(_),_, _, _) => | |||
(seq) => (seq + DeprecatedVarLengthBindingNotification(p.position, variable.name), None) | |||
case p@RelationshipPattern(_,_,_,Some(_),_,true) => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
code style: space after comma.
) | ||
|
||
private def LegacyCompatibleRelTypeName: Rule1[(Boolean,ast.RelTypeName)] = | ||
((":" ~ push(true)) | EMPTY ~ push(false)) ~~ RelTypeName ~~>> ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess this is the line that sets the warning condition. So the warning will be emitted when doing
MATCH ()-[:FOO | :BAR]->()
but not when doing
MATCH ()-[:FOO | BAR]->()
and the presence of an inlined property predicate is not checked for. It would be nice to have some acceptance tests that confirms this interpretation.
DEPRECATED_BINDING_VAR_LENGTH_RELATIONSHIP( | ||
SeverityLevel.WARNING, | ||
Status.Statement.FeatureDeprecationWarning, | ||
"Binding relationships to a list in a variable length pattern is deprecated." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't find where this condition is checked, but perhaps that's still TODO?
bbb2831
to
52bf95a
Compare
I wonder if we also need to deprecate binding together with colon in alternatives. That would make the future syntax easier to implement. i.e.
|
d11fd04
to
b9d1ceb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I looked at this pairing w mats and am in favour of this.
I'm trying to model a situation where there is a heirarchy of organisations such that OrgA can be a MEMBEROF OrgB. Similarly User1 can be MEMBEROF OrgA. Finally a person P1 can give CONSENT to access their account details to either a User or an Organisation, with the expectation being that consent can flow from an Organisation to it's member orgs and ultimately to users. |
@NicholasIoanJones The canonical way, as outlined above, suggests your query in this form:
Note: Cypher style guide recommends property keys be written in camelCase with small starting character. |
Thanks Mats, that works perfectly. I obviously need to read more and try out more to get my head better in tune with this. Style comment noted as well. |
Ensure that Neo4j Cypher produces warning for pattern matching syntax that will be unsupported or have different semantics in future versions of Cypher.
Binding of relationships from variable length patterns is deprecated.
Queries such as:
Will generate a warning. The canonical way to write such a query is:
Using colon for each relationship type in a listing of multiple alternative relationship types in conjunction with using in-lined property predicates will change semantics in future versions.
This query:
Currently means that the property predicate should apply to all relationships, but in future versions it will mean that the property predicate applies to relationships with type
C
, while no property predicates apply for relationships of typeA
orB
. On order to achieve the current behaviour in future versions as well, only a single initial colon should be used, like so:changelog: Deprecated syntax for legacy patterns: