orientjs
orientjs copied to clipboard
Order by generate not valid strict SQL when ordered by more attributes
Hello, When I try to order result with order('scheduleDate DESC, @rid DESC'), it generates non valid strict SQL: SELECT FROM Gift ORDER BY (scheduleDate DESC, @rid DESC) Error: com.orientechnologies.orient.core.sql.OCommandSQLParsingException: Error on parsing command at position #0: Error parsing query: SELECT FROM Gift ORDER BY (scheduleDate DESC, @rid DESC) Encountered " "," ", "" at line 1, column 45. Was expecting one of: ")" ... ")" ...
When I remove parenthesis SELECT FROM Gift ORDER BY scheduleDate DESC, @rid DESC, everything works as expected.
I am using OrientDB 2.1.8
Is there some workaround?
Thank you
And rewrite it in raw query is not solution. I have hundreds of queries with sorting based on multiple attributes. I tested it also on 2.1.16 and same problem.
Hi @janjilek
There is no workaround, apart from what you already found (removing the parentheses). As I wrote in another issue, parentheses in the ORDER BY condition have no meaning, this is why they are not supported.
Thanks
Luigi
The problem is, that this query is generated by OrientJS query builder, so I cannot execute strict queries. And only solution is to rewrite every query without query builder => so no solution at all.
.order('scheduleDate DESC, @rid DESC') generates (scheduleDate DESC, @rid DESC) and not scheduleDate DESC, @rid DESC
ouch... so the problem is in OrientJS! Forwarding it to @maggiolo00 for a quick fix
Thanks
Luigi
So the problem is in the driver. The solution is to remove if (utils.requiresParens(item)) { return '(' + item + ')'; } On line 809 in statement.js and return only item :-)
Not sure, I think that method is also used by other parts of the query builder. We will check it asap
Thanks
Luigi
I found workaround, use of array: .order(['scheduleDate DESC', '@rid DESC'])
Hi, when will you release fix for this?
Thank you