-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Bug/#8011 ordering with arithmetic expression #8012
base: 2.20.x
Are you sure you want to change the base?
Bug/#8011 ordering with arithmetic expression #8012
Conversation
Is this something Doctrine ORM has ever even tackled? |
See #8011 (comment) for some more discoveries. |
e531738
to
66c95a6
Compare
There hasn't been any activity on this pull request in the past 90 days, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 7 days. |
Still considered valid I assume. I'm not sure about the fix however, so somebody needs to look into that please. |
@greg0ire Should this target 2.21.x or 3.4.x? |
2.20 since it's a bugfix |
@sgehrig Please rebase your branch to 2.20.x and resolve conflicts in Parser.php. |
…der by item with arithmetic expression Not sure whether this covers the whole problem regarding complex expressions in order by items but it fixes the provided test cases
…s - just one bracket does not work) just one bracket (...) gives Exception : [Doctrine\ORM\Query\QueryException] [Syntax Error] line 0, col xx: Error: Expected Doctrine\ORM\Query\Lexer::T_IDENTIFIER, got '('
deb0f67
to
0e4786d
Compare
@SenseException Done. Thanks for looking into my PR. |
Signed-off-by: Stefan Gehrig <stefan.gehrig.hn@googlemail.com>
Signed-off-by: Stefan Gehrig <stefan.gehrig.hn@googlemail.com>
Coming back to this one as this makes the tests fail. I'm not entirely sure, but I assume the issue is that e.g.
that references Even the documentation lists a similar example: $query = $em->createQuery('SELECT u, u.posts_count + u.likes_count AS HIDDEN score FROM CmsUser u ORDER BY score');
$users = $query->getResult(); // array of User objects I could not find a test case that handles this scenario however. |
This is the PR requested for issue #8011.
It includes tests for some arithmetic expressions being used in
ORDER BY
clauses of a DQL query.ORDER BY p.id + p.id ASC
✅ORDER BY 1 + p.id ASC
🚫ORDER BY p.id + 1 ASC
✅ORDER BY s + 1 DESC
🚫 (wheres
is aResultVariable
)ORDER BY 1 + s DESC
🚫 (wheres
is aResultVariable
)ORDER BY s + p.id DESC
🚫 (wheres
is aResultVariable
)ORDER BY p.id + s DESC
✅ (wheres
is aResultVariable
)