Skip to content
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

Label Expressions not handled (but relationship type expressions are) #86

Open
flaar94 opened this issue Sep 27, 2023 · 1 comment
Open

Comments

@flaar94
Copy link

flaar94 commented Sep 27, 2023

Hi,

First of all, thanks for all your work! This plugin is a real lifesaver when working with complicated neo4j queries.

I have noticed that it doesn't seem to support most label expressions for cypher (https://neo4j.com/docs/cypher-manual/current/patterns/reference/#label-expressions), even when the corresponding expression is supported for relationship type expressions. In particular '|', eg:
MATCH (:Person|Company) is marked as incorrect while something like MATCH ()-[:WORKS_FOR|OWNS]->() is handled correctly. The other one I noticed is '!' like MATCH (:!Company) doesn't work for either labels or relationship types, but I don't use that one very often. The docs claim the syntax for labels and types are the same, so I hope it wouldn't be too much work to fix the former issue since it's apparently already done for relationship types

Anyways, Thank you!

@flaar94
Copy link
Author

flaar94 commented Sep 29, 2023

Glancing around the code, I'm guessing the main relevant parts are



NodePattern ::= "(" Variable? NodeLabels? Properties? Where? ")" {pin=1}

I'm not very good at Java, but it seems like you could mostly copy how relationshipType is doing it and replace

NodePattern ::= "(" Variable? NodeLabels? Properties? Where? ")" {pin=1}

With something like

NodePattern ::= "(" Variable? LabelExpression? Properties? Where? ")" {pin=1} 
LabelExpression ::= ":" "!"? LabelName ( ( "|" | ":" ) "!"? LabelName)* {pin=1}

Looking at it, I notice that relationshipTypes doesn't handle expressions like [:WORKS_FOR:OWNS] either, so this might fix that? I'm not really sure what that pin is doing though. It's still a subset of the label-expression syntax, but seems to take care of most simple uses without getting recursive. NodeLabels is used in SET, so I'm guessing you probably shouldn't change it, although it's also used in this line:

Anyways, not sure if any of that is helpful at all since I only have a superficial grasp of what is going on here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant