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

MSSQL adds a redundant ORDER BY clause when with subquery with ORDER BY #4437

Closed
trusek opened this issue Nov 17, 2020 · 1 comment · Fixed by #4438
Closed

MSSQL adds a redundant ORDER BY clause when with subquery with ORDER BY #4437

trusek opened this issue Nov 17, 2020 · 1 comment · Fixed by #4438

Comments

@trusek
Copy link
Contributor

trusek commented Nov 17, 2020

Bug Report

Q A
BC Break no
Version 2.12

Summary

I have a query where in the ORDER BY clause I have a subquery with an ORDER BY clause, when I limit the query I get an incorrect query with redundant ORDER BY clause

Current behaviour

Input sql

SELECT col1 FROM test ORDER BY ( SELECT col2 from test ORDER BY col2 )

Output sql

SELECT col1 FROM test ORDER BY ( SELECT col2 from test ORDER BY col2 ) ORDER BY (SELECT 0) OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY

How to reproduce

/** @var SQLServerPlatform */
$platform;
$querySql = 'SELECT col1 FROM test ORDER BY ( SELECT col2 from test ORDER BY col2 )';
$sql = $platform->modifyLimitQuery($querySql, 10);

Expected behaviour

SELECT col1 FROM test ORDER BY ( SELECT col2 from test ORDER BY col2 ) OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY
trusek added a commit to trusek/dbal that referenced this issue Nov 17, 2020
morozov added a commit that referenced this issue Dec 7, 2020
#4437 MSSQL adds a redundant ORDER BY clause when with subquery with …
@morozov morozov closed this as completed Dec 7, 2020
@morozov morozov added this to the 2.12.2 milestone Dec 7, 2020
@morozov morozov modified the milestones: 2.12.2, 2.13.0 Apr 8, 2021
@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 27, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants