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

[pb3CtuNX] Adds convert.paths.toTree to deprecate old convert.toTree #4044

Merged
merged 5 commits into from
Apr 30, 2024

Conversation

ncordon
Copy link
Contributor

@ncordon ncordon commented Apr 10, 2024

What

Adds a new method convert.paths.toTree that deprecates convert.toTree.

Closes #3996, #3997

Why

There were several problems with the old method. For paths:

v1 -> v2 -> v3
v2 -> v2 //self-loop

it was outputting:

v1 -> v2 -> v2
v2 -> v2

instead of:

v1 -> v2 -> v2
         -> v3

This PR adds a new method that:

  • Fixes the behaviour for cyclic paths.
  • Fixes the behaviour for bidirectional paths.
  • Fixes the properties filter for both of the method when the nodes have several labels.

@ncordon ncordon added bug 4.4 team-cypher-surface Cypher Surface team should review the PR not-ready-for-merge labels Apr 10, 2024
@ncordon ncordon changed the title [pb3CtuNX] Fixes convert.toTree bug [pb3CtuNX] Adds convert.paths.toTree to deprecate old convert.toTree Apr 11, 2024
@@ -231,6 +231,73 @@ public Stream<MapResult> toTree(
.map(MapResult::new);
}

@Procedure("apoc.paths.toJsonTree")
@Description(
"apoc.paths.toJsonTree([paths],[lowerCaseRels=true], [config]) creates a stream of nested documents representing the at least one root of these paths")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be good with different a different description for the new toTree so that it is possible to understand what the difference is.

Copy link
Contributor

@JoelBergstrand JoelBergstrand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great!

@ncordon ncordon merged commit 2abb6f8 into 4.4 Apr 30, 2024
12 checks passed
@ncordon ncordon deleted the toTree-bug branch April 30, 2024 11:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4.4 bug team-cypher-surface Cypher Surface team should review the PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

apoc.convert.toTree() returns wrong result if there is a cycle from root of the path
2 participants