-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
#4437 MSSQL adds a redundant ORDER BY clause when with subquery with … #4438
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the patch, @trusek. In addition to the unit test, it would be good to have an integration test that confirms that the simplified SQL also works and yields the expected results. See the testing guidelines and Doctrine\Tests\DBAL\Functional\ModifyLimitQueryTest
.
I have a problem with an integration test. In SQL Server, the ORDER BY clause in a subquery must come together with TOP, OFFEST or FOR XML (ms_docs), so I figured I'd use a double |
I have no idea how to create a functional test for this case. |
It should be the query that made you make this change in the codebase.
Please make it as generic as possible and skip on those platforms that don't support this syntax. |
I used QueryBuilder to create a subquery with ORDER BY. Which eliminated syntax errors for other database engines.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apart from the new protected
method, looks good. Please squash.
Thanks, @trusek. |
Summary
Currently, it is checking the last ORDER BY clause if after this clause the number of open brackets is different from the number of closed brackets, then it adds an ORDER BY clause.
I changed the logic so that ORDER BY was added when, among all ORDER BY instances found in the query, the condition that number of open brackets is different than number of closed brackets for a particular clause is met.
Overall, I check every occurrence of ORDER BY, not just the last.