From a460d35d9cf45fdc8ed80f0c11ef32614d4ed130 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sami=20Koskim=C3=A4ki?= Date: Sun, 10 Sep 2023 22:12:28 +0300 Subject: [PATCH] add test with limit and offset --- test/node/src/select.test.ts | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/test/node/src/select.test.ts b/test/node/src/select.test.ts index 2f9222506..b0442af12 100644 --- a/test/node/src/select.test.ts +++ b/test/node/src/select.test.ts @@ -986,6 +986,35 @@ for (const dialect of DIALECTS) { } } + if (dialect !== 'mssql') { + it('should create a select query with limit and offset', async () => { + const query = ctx.db + .selectFrom('person') + .select('first_name') + .limit(2) + .offset(1) + + testSql(query, dialect, { + postgres: { + sql: `select "first_name" from "person" limit $1 offset $2`, + parameters: [2, 1], + }, + mysql: { + sql: 'select `first_name` from `person` limit ? offset ?', + parameters: [2, 1], + }, + mssql: NOT_SUPPORTED, + sqlite: { + sql: 'select "first_name" from "person" limit ? offset ?', + parameters: [2, 1], + }, + }) + + const result = await query.execute() + expect(result).to.have.length(2) + }) + } + it('should create a select statement without a `from` clause', async () => { const query = ctx.db.selectNoFrom((eb) => [ eb.selectNoFrom(eb.lit(1).as('one')).as('one'),