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

SortOrder escaping bug #486

Closed
oellan opened this issue May 12, 2018 · 3 comments
Closed

SortOrder escaping bug #486

oellan opened this issue May 12, 2018 · 3 comments

Comments

@oellan
Copy link

oellan commented May 12, 2018

Expected Behavior

The method void org.neo4j.ogm.session.resolvePropertyAnnotations(Class, SortOrder) should escape the properties in the SortOrder object only once.

Current Behavior

The method void org.neo4j.ogm.session.resolvePropertyAnnotations(Class, SortOrder) is escaping the SortOrder's properties each time it is called.

Possible Solution

Create a private flag to check if the SortOrder's properties are already escaped.

Steps to Reproduce (for bugs)

Call any getAll() method from a session with a provided SortOrder instance with at least one property to sort.

Reference Stacktrace

org.neo4j.driver.v1.exceptions.ClientException: Invalid input 'n': expected '`', '.', whitespace, '(', node labels, '[', "=~", IN, STARTS, ENDS, CONTAINS, IS, '^', '*', '/', '%', '+', '-', '=', "<>", "!=", '<', '>', "<=", ">=", AND, XOR, OR, DESCENDING, DESC, ASCENDING, ASC, ',', SKIP, LIMIT, WHERE, LOAD CSV, FROM, INTO, START, MATCH, UNWIND, MERGE, CREATE GRAPH >>, CREATE >> GRAPH, CREATE GRAPH, CREATE, SET, DELETE GRAPHS, DELETE, REMOVE, FOREACH, WITH, CALL, PERSIST, RELOCATE, RETURN, SNAPSHOT, UNION, ';' or end of input (line 1, column 39 (offset: 38))
"MATCH (n:`Anime`) WITH n ORDER BY n.``name`` RETURN n, ID(n)"
                                       ^

Your Environment

  • OGM Version used: 3.1.0
  • Java Version used: 10
  • Neo4J Version used: 3.5.5
  • Bolt Driver Version used: 3.1.0
  • Operating System and Version: Windows 10 (64 bits)
  • Link to your project: none
@oellan oellan mentioned this issue May 12, 2018
9 tasks
@meistermeier
Copy link
Collaborator

Thanks for reporting this.
I tried to reproduce the problem but was not successful. Do you have any reference code/sample/snippet/test that will generate the wrong query?
There are tests for simple sorting like you described it in our code base e.g.


that do not show any problems even when I run this with Java 10.

@oellan
Copy link
Author

oellan commented May 14, 2018

Actually, I am reusing the same SortOder instance each time when I fetch nodes with getAll(). In the tests, a new SortOrder instance is created when the getAll() method is called. I think this is why you can't reproduce this bug with the test you provided above.

@meistermeier
Copy link
Collaborator

Great, now I can see your problem you have.

meistermeier added a commit that referenced this issue May 28, 2018
meistermeier added a commit that referenced this issue May 28, 2018
The properties used in a SortOrder object are now processed before every
usage. This makes the SortOrder class reusable in multiple calls and
even allows usage for other domain classes that also have the same
properties to get ordered by.

Fixes #486
meistermeier added a commit that referenced this issue May 29, 2018
The properties used in a SortOrder object are now processed before every
usage. This makes the SortOrder class reusable in multiple calls and
even allows usage for other domain classes that also have the same
properties to get ordered by.

Fixes #486
meistermeier added a commit that referenced this issue Jun 21, 2018
The properties used in a SortOrder object are now processed before every
usage. This makes the SortOrder class reusable in multiple calls and
even allows usage for other domain classes that also have the same
properties to get ordered by.

Fixes #486
Backport to 3.0.

(cherry picked from commit 1a0924d)
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