Skip to content

Commit

Permalink
fix: using limit and offset together in MSSql
Browse files Browse the repository at this point in the history
Thanks to @ykphuah
  • Loading branch information
ykphuah authored Jul 30, 2020
1 parent 280bf19 commit 9ba875c
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion packages/cubejs-schema-compiler/adapter/MssqlQuery.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,17 @@ class MssqlQuery extends BaseQuery {
}

groupByDimensionLimit() {
return this.offset ? ` OFFSET ${parseInt(this.offset, 10)} ROWS` : '';
if (this.rowLimit) {
return this.offset ? ` OFFSET ${parseInt(this.offset, 10)} ROWS FETCH NEXT ${parseInt(this.rowLimit, 10)} ROWS ONLY` : '';
} else {
return this.offset ? ` OFFSET ${parseInt(this.offset, 10)} ROWS` : '';
}
}

topLimit() {
if (this.offset) {
return '';
}
return this.rowLimit === null ? '' : ` TOP ${this.rowLimit && parseInt(this.rowLimit, 10) || 10000}`;
}

Expand Down

0 comments on commit 9ba875c

Please sign in to comment.