Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fix OrderByItem parser to proceed with SimpleArithmetic expression before function#8277

Merged
ostrolucky merged 1 commit into
doctrine:2.7from
ipernet:fix-7626
Sep 20, 2020
Merged

Fix OrderByItem parser to proceed with SimpleArithmetic expression before function#8277
ostrolucky merged 1 commit into
doctrine:2.7from
ipernet:fix-7626

Conversation

@ipernet
Copy link
Copy Markdown
Contributor

@ipernet ipernet commented Sep 20, 2020

Hi,

Fix #7626

There is parser bug for OrderByItem(), where a function is detected before a SimpleArithmeticExpression while it should be the reverse: simple arithmetic expressions can start with a function too, and thus they should be matched first if present.

This fix enables the use of expression in sorting and with window functions.

@greg0ire
Copy link
Copy Markdown
Member

Please improve your commit message according to the contributing guide.

Also, please associate your email address with your Github account, or change the
email in your commits to an address already associated with it. If you do not
want to expose your personal email address, you may use
[email protected], that way we can still reach you through Github.
Additionally, you will get credit for this contribution on your Github profile.

Comment thread lib/Doctrine/ORM/Query/Parser.php Outdated
Comment thread tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php Outdated
Comment thread tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php Outdated
Comment thread tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php Outdated
@greg0ire
Copy link
Copy Markdown
Member

Re-order OrderByIdem parser to proceed with SimpleArithmetic expressions before functions

  • The subject line should be less than 50 chars, you can and should use the commit message body if you need more; in fact, the great explanation you put in your first Github message should go there.
  • OrderByIdem => OrderByItem

Here is how it could look like:

Parse simple arithmetic expressions before functions

There is parser bug for OrderByItem(), where a function is detected
before a SimpleArithmeticExpression while it should be the reverse:
simple arithmetic expressions can start with a function too, and thus
they should be matched first if present.

This fix enables the use of expressions in sorting and with window
functions.

@greg0ire greg0ire added the Bug label Sep 20, 2020
@ipernet ipernet force-pushed the fix-7626 branch 2 times, most recently from 37633cc to 1051473 Compare September 20, 2020 09:45
There is parser bug for OrderByItem(), where a function is detected
before a SimpleArithmeticExpression while it should be the reverse:
simple arithmetic expressions can start with a function too, and thus
they should be matched first if present.

This fix enables the use of expressions in sorting and with window
functions.
@ipernet
Copy link
Copy Markdown
Contributor Author

ipernet commented Sep 20, 2020

Thanks @greg0ire for your feedback, they should now all be resolved

Copy link
Copy Markdown
Member

@SenseException SenseException left a comment

Choose a reason for hiding this comment

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

I was playing around with DQL and these changes and couldn't find anything that broke with it. The order of cases could have had an impact on other use cases, but it didn't.

@ostrolucky ostrolucky added this to the 2.7.4 milestone Sep 20, 2020
@ostrolucky ostrolucky merged commit 7066702 into doctrine:2.7 Sep 20, 2020
@ipernet ipernet deleted the fix-7626 branch September 20, 2020 18:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Failed parse the condition in ORDER BY

4 participants