Skip to content

Commit

Permalink
Add support for "limit 0"
Browse files Browse the repository at this point in the history
  • Loading branch information
sillvva committed May 4, 2024
1 parent a78eefe commit 392d4e9
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
10 changes: 8 additions & 2 deletions drizzle-orm/src/mysql-core/dialect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,10 @@ export class MySqlDialect {
groupBySql = sql` group by ${sql.join(groupBy, sql`, `)}`;
}

const limitSql = limit ? sql` limit ${limit}` : undefined;
const limitSql =
typeof limit === "object" || (typeof limit === "number" && limit >= 0)
? sql` limit ${limit}`
: undefined;

const offsetSql = offset ? sql` offset ${offset}` : undefined;

Expand Down Expand Up @@ -400,7 +403,10 @@ export class MySqlDialect {
orderBySql = sql` order by ${sql.join(orderByValues, sql`, `)} `;
}

const limitSql = limit ? sql` limit ${limit}` : undefined;
const limitSql =
typeof limit === "object" || (typeof limit === "number" && limit >= 0)
? sql` limit ${limit}`
: undefined;

const operatorChunk = sql.raw(`${type} ${isAll ? 'all ' : ''}`);

Expand Down
10 changes: 8 additions & 2 deletions drizzle-orm/src/pg-core/dialect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,10 @@ export class PgDialect {
groupBySql = sql` group by ${sql.join(groupBy, sql`, `)}`;
}

const limitSql = limit ? sql` limit ${limit}` : undefined;
const limitSql =
typeof limit === "object" || (typeof limit === "number" && limit >= 0)
? sql` limit ${limit}`
: undefined;

const offsetSql = offset ? sql` offset ${offset}` : undefined;

Expand Down Expand Up @@ -443,7 +446,10 @@ export class PgDialect {
orderBySql = sql` order by ${sql.join(orderByValues, sql`, `)} `;
}

const limitSql = limit ? sql` limit ${limit}` : undefined;
const limitSql =
typeof limit === "object" || (typeof limit === "number" && limit >= 0)
? sql` limit ${limit}`
: undefined;

const operatorChunk = sql.raw(`${type} ${isAll ? 'all ' : ''}`);

Expand Down
10 changes: 8 additions & 2 deletions drizzle-orm/src/sqlite-core/dialect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,10 @@ export abstract class SQLiteDialect {

const orderBySql = orderByList.length > 0 ? sql` order by ${sql.join(orderByList)}` : undefined;

const limitSql = limit ? sql` limit ${limit}` : undefined;
const limitSql =
typeof limit === "object" || (typeof limit === "number" && limit >= 0)
? sql` limit ${limit}`
: undefined;

const offsetSql = offset ? sql` offset ${offset}` : undefined;

Expand Down Expand Up @@ -362,7 +365,10 @@ export abstract class SQLiteDialect {
orderBySql = sql` order by ${sql.join(orderByValues, sql`, `)}`;
}

const limitSql = limit ? sql` limit ${limit}` : undefined;
const limitSql =
typeof limit === "object" || (typeof limit === "number" && limit >= 0)
? sql` limit ${limit}`
: undefined;

const operatorChunk = sql.raw(`${type} ${isAll ? 'all ' : ''}`);

Expand Down

0 comments on commit 392d4e9

Please sign in to comment.