Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Strange behavior when querying for Nodes with self-referential relationships #600

Closed
blevine opened this Issue · 4 comments

4 participants

@blevine

I have reproduced this on 1.8.1 and 1.8.2.

Create a node that has 1 link to itself. The query below is designed to return the node and its relationships separated into incoming and outgoing relationships. It also includes the start nodes (for incoming relationships) and end nodes (for outgoing relationships).

START n=node(12) MATCH n<-[links_n_in?]-(n_from),n-[links_n_out?]->(n_to) RETURN n,COLLECT(n_from) AS n_from,COLLECT(links_n_in) AS links_n_in,COLLECT(n_to) AS n_to,COLLECT(links_n_out) AS links_n_out

When the node has 1 self-referential relationship, either the links_n_in or links_n_out array is populated with the expected relationships, but not both. And the behavior seems to be nondeterministic. Sometimes the links_n_in array is populated and sometimes the links_n_out array is populated. Note the use of optional relationships in the query. When I do not use optional relationships (omit the '?'), this behavior does not occur and both arrays are populated as expected.

When the node has 2 self-referential relationships, this problem does not occur and both arrays are populated with 2 relationships as expected. This is true regardless of whether optional relationships are used in the query.

However, when the node has 3 self-referential relationships, both arrays are populated with 6 relationships instead of the expected 3. In other words, each relationship is duplicated. Similar behavior also results with more than 3 relationships. This occurs regardless of whether optional relationships are used in the query. Note that adding DISTINCT inside COLLECT(links_n_in) and COLLECT(links_n_out) fixes this problem.

@wfreeman

I think this may have been fixed. Can you try reproducing it in console? (and share your sample graph here)

@blevine

Fixed in what release?

@peterneubauer

Try Neo4j 1.9. M05

@jakewins
Collaborator

Assuming this has in fact been resolved then. Please re-open if you come across this again @blevine

@jakewins jakewins closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.