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

Multiple matches generate unexpected cypher #327

Open
aekobear opened this issue Feb 11, 2019 · 1 comment
Open

Multiple matches generate unexpected cypher #327

aekobear opened this issue Feb 11, 2019 · 1 comment

Comments

@aekobear
Copy link

When using the Query object to create a query with multiple match statements, the statements are merged into a single match. The resulting cypher produces different results than it would have, had all the matches been preserved.

Given that there are situations where multiple matches are explicitly desired, and given that there is already a notation for writing a multi-pattern match:

q.match('pattern a', 'pattern b')

I think it is most intuitive to have multiple matches retained when the query is converted to cypher.

Additional information which could be helpful if relevent to your issue:

Code example (inline, gist, or repo)

For example, take a graph of a Repo named Test and a chain of dependencies named D1, D2 and D3:
image

The query:

q.match('(r:Repo { name: "Test" })-[*]-(d)')
  .match('(d)-[e]-()')
  .return(:d, :e)

generates the cypher:

MATCH (r:Repo { name: "Test" })-[*]-(d), (d)-[e]-() RETURN d, e

which returns only the dependencies D1 and D2.

Forcing multiple matches with a break:

q.match('(r:Repo { name: "Test" })-[*]-(d)')
  .break
  .match('(d)-[e]-()')
  .return(:d, :e)

generates the cypher:

MATCH (r:Repo { name: "Test" })-[*]-(d) MATCH (d)-[e]-() RETURN d, e

which returns all dependencies D1, D2 and D3.

Runtime information:

Neo4j database version: 3.5.0
neo4j gem version: N/A
neo4j-core gem version: 9.0.0

@jorroll
Copy link

jorroll commented Feb 11, 2019

Related to #255

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

2 participants