-
Notifications
You must be signed in to change notification settings - Fork 35
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
Pagination fails with distinct (Grammer: MS SQL SERVER) #213
Comments
This appears to be still happening in the latest version |
Can you provide me with a query that is breaking? |
SELECT COUNT(DISTINCT *) AS "aggregate" FROM [batches] INNER JOIN [projects] ON [projects].[project_id] = [batches].[project_id] INNER JOIN [users] ON [users].[user_id] = [batches].[owner_user_id] INNER JOIN [statuses] ON [statuses].[statusID] = [batches].[status] INNER JOIN [labels] ON [labels].[label_key] = [batches].[department] INNER JOIN [assignments] ON [assignments].[batch_id] = [batches].[batch_id] WHERE [labels].[type] = 'dept_code' AND [batches].[status] = '1' AND [batches].[department] = '1' |
Is that the correct SQL or incorrect? Also, can I get the qb code that is generating that? |
that is the incorrect sql. (distinct can't be in the aggregate function () ) |
|
looks like the formatting is lost even using the code formatting option. |
FYI. In case I did not clarify. This error occurs when invoking the paginate method. |
When drafting a QB query with distinct() it constructs an invalid query select list:
`
I found that by removing the reference to the DISTINCT keyword in the following function, the paginate works as expected:
Wondering why this built to test if distinct is present?
`
private string function compileAggregate( required QueryBuilder query, required struct aggregate ) {
if ( aggregate.isEmpty() ) {
return "";
}
return "SELECT #uCase( aggregate.type )#(#query.getDistinct() ? "DISTINCT " : ""##wrapColumn( aggregate.column )#) AS ""aggregate""";
}
`
The text was updated successfully, but these errors were encountered: