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

Expand Path methods don't handle label filters where the label filter contains characters that would normally need to be escaped using backticks #107

Closed
neo-technology-build-agent opened this issue Sep 1, 2022 · 2 comments
Labels
bug Something isn't working

Comments

@neo-technology-build-agent
Copy link
Collaborator

Issue by mdw00d
Friday Feb 07, 2020 at 18:37 GMT
Originally opened as neo4j-contrib/neo4j-apoc-procedures#1407


Expected Behavior

If one is working with a graph where properties and labels contain characters that might normally need to be escaped, including characters such as the special filter qualifiers, then the library does not function as expected.

For example, suppose a node has both the label http://www.w3.org/2002/07/owl#Class and (for the sake of demonstrating this issue), the label OwlClass.

I would expect that

MATCH (v1:`http://example.com/abc#Object`) where v1.uri = "node1e0g5tmg9x4628" call apoc.path.expand(v1, '>|<', '/OwlClass', 0, 2) yield path return distinct nodes(path)

and

MATCH (v1:`http://example.com/abc#Object`) where v1.uri = "node1e0g5tmg9x4628" call apoc.path.expand(v1, '>|<', '/http://www.w3.org/2002/07/owl#Class', 0, 2) yield path return distinct nodes(path)

to return the same results, but the later returns no response while the former returns content.

Versions

  • OS:
  • Neo4j: 3.5
  • Neo4j-Apoc: 3.5.0.6
@neo-technology-build-agent
Copy link
Collaborator Author

Comment by mdw00d
Sunday Feb 09, 2020 at 00:50 GMT


This behavior is also observed using APOC 3.5.0.7.

@gem-neo4j gem-neo4j added the bug Something isn't working label Apr 6, 2023
@gem-neo4j
Copy link
Contributor

Hi there! This is due to how labels filters are created. In this case, the colon : represents a compound label. So in your second example, the termination node filter is actually looking for the node with 2 labels: /http and `://www.w3.org/2002/07/owl#Class'. This is fixed by adding an escape before the colon:

MATCH (v1:`http://example.com/abc#Object`)
WHERE v1.uri = "node1e0g5tmg9x4628"
CALL apoc.path.expand(v1, '>|<', '/http\://www.w3.org/2002/07/owl#Class', 0, 2)
YIELD path RETURN distinct nodes(path)

I will update the docs to make this clearer :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants