Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for "limit 0" #2255

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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