-
Notifications
You must be signed in to change notification settings - Fork 187
Fix SQL Server error code 145 for select distinct with result limited queries. #964
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -813,11 +813,11 @@ public void printSQLSelectStatement(DatabaseCall call, ExpressionSQLPrinter prin | |
return; | ||
} | ||
|
||
// OFFSET + FETCH NEXT requires ORDER BY, so add an ordering if there are none | ||
// this SQL will satisfy the query parser without actually changing the ordering of the rows | ||
// OFFSET + FETCH NEXT requires ORDER BY | ||
List<Expression> orderBy = statement.getOrderByExpressions(); | ||
if (orderBy.isEmpty()) { | ||
orderBy.add(statement.getBuilder().literal("ROW_NUMBER() OVER (ORDER BY (SELECT null))")); | ||
super.printSQLSelectStatement(call, printer, statement); | ||
return; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry I'm not specialist for MS SQL, but could You please provide some example and simple SQL query with |
||
|
||
// decide exact syntax to use, depending on whether a limit is specified (could just have an offset) | ||
|
Uh oh!
There was an error while loading. Please reload this page.