Skip to content

Commit 9ba875c

Browse files
authored
fix: using limit and offset together in MSSql
Thanks to @ykphuah
1 parent 280bf19 commit 9ba875c

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

packages/cubejs-schema-compiler/adapter/MssqlQuery.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,17 @@ class MssqlQuery extends BaseQuery {
7575
}
7676

7777
groupByDimensionLimit() {
78-
return this.offset ? ` OFFSET ${parseInt(this.offset, 10)} ROWS` : '';
78+
if (this.rowLimit) {
79+
return this.offset ? ` OFFSET ${parseInt(this.offset, 10)} ROWS FETCH NEXT ${parseInt(this.rowLimit, 10)} ROWS ONLY` : '';
80+
} else {
81+
return this.offset ? ` OFFSET ${parseInt(this.offset, 10)} ROWS` : '';
82+
}
7983
}
8084

8185
topLimit() {
86+
if (this.offset) {
87+
return '';
88+
}
8289
return this.rowLimit === null ? '' : ` TOP ${this.rowLimit && parseInt(this.rowLimit, 10) || 10000}`;
8390
}
8491

0 commit comments

Comments
 (0)