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

SQL Server: Exception when DISTINCT is used with result limited queries #963

Open
kaizimmerm opened this issue Nov 15, 2020 · 1 comment · May be fixed by #964
Open

SQL Server: Exception when DISTINCT is used with result limited queries #963

kaizimmerm opened this issue Nov 15, 2020 · 1 comment · May be fixed by #964

Comments

@kaizimmerm
Copy link

Hi,

this change #300 unfortunately causes errors when the query is using distinct: com.microsoft.sqlserver.jdbc.SQLServerException: ORDER BY items must appear in the select list if SELECT DISTINCT is specified.

Maybe it is better not to try to trick the query parser here:

orderBy.add(statement.getBuilder().literal("ROW_NUMBER() OVER (ORDER BY (SELECT null))"));

...but step out in that case:

super.printSQLSelectStatement(call, printer, statement);
return;

Kai

@johnmanko
Copy link

This is a critical blocker for us. @kaizimmerm, were you able to work around this without losing original functionality?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants