Skip to content

Commit

Permalink
fix(api-gateway): fixes an issue where queries to get the total count…
Browse files Browse the repository at this point in the history
… of results were incorrectly applying sorting from the original query and also were getting default ordering applied when the query ordering was stripped out (#8060) Thanks @rdwoodring!

* fix(api-gateway) fix(schema-compiler): fixes an issue where queries to get the total count of results were incorrectly applying sorting from the original query and also were getting default ordering applied when the query ordering was stripped out

* fix(api-gateway): add missing semicolon

---------

Co-authored-by: Ryan Woodring <[email protected]>
  • Loading branch information
rdwoodring and Ryan Woodring authored Sep 9, 2024
1 parent 20bfec7 commit 863f370
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions packages/cubejs-api-gateway/src/gateway.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1552,9 +1552,13 @@ class ApiGateway {
if (normalizedQuery.total) {
const normalizedTotal = structuredClone(normalizedQuery);
normalizedTotal.totalQuery = true;

delete normalizedTotal.order;

normalizedTotal.limit = null;
normalizedTotal.rowLimit = null;
normalizedTotal.offset = null;

const [totalQuery] = await this.getSqlQueriesInternal(
context,
[normalizedTotal],
Expand Down
2 changes: 1 addition & 1 deletion packages/cubejs-schema-compiler/src/adapter/BaseQuery.js
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ export class BaseQuery {
}

defaultOrder() {
if (this.options.preAggregationQuery) {
if (this.options.preAggregationQuery || this.options.totalQuery) {
return [];
}

Expand Down

0 comments on commit 863f370

Please sign in to comment.