Fixed mandatory LIMIT generation in case of firstRow>0

This commit is contained in:
Serhii Dakhnii
2022-11-30 21:36:08 +02:00
parent 6c6ec3663a
commit 3277fe81a1
2 changed files with 6 additions and 6 deletions
@@ -31,12 +31,12 @@ public class LimitOffsetSqlLimiter implements SqlLimiter {
int firstRow = request.getFirstRow();
int maxRows = request.getMaxRows();
if (maxRows > 0 || firstRow > 0) {
if (maxRows > 0) {
sb.append(" ").append(LIMIT).append(" ").append(maxRows);
if (firstRow > 0) {
sb.append(" ").append(OFFSET).append(" ");
sb.append(firstRow);
}
}
if (firstRow > 0) {
sb.append(" ").append(OFFSET).append(" ");
sb.append(firstRow);
}
String sql = request.getDbPlatform().completeSql(sb.toString(), request.getOrmQuery());
@@ -40,7 +40,7 @@ public class TestLimitQuery extends BaseTestCase {
String sql = query.getGeneratedSql();
if (isH2()) {
assertThat(sql).contains("offset 3");
assertThat(sql).contains("limit 0");
assertThat(sql).doesNotContain("limit");
}
}