Skip to content

Commit

Permalink
add test with limit and offset
Browse files Browse the repository at this point in the history
  • Loading branch information
koskimas authored and Gaspero committed Oct 2, 2023
1 parent c665eb5 commit a460d35
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions test/node/src/select.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down

0 comments on commit a460d35

Please sign in to comment.