@knorm/postgres
Advanced tools
Comparing version 1.1.1 to 1.1.2
@@ -324,7 +324,7 @@ const { Knorm } = require('@knorm/knorm'); | ||
if (this.options.limit) { | ||
if (this.options.limit !== undefined) { | ||
sql.limit(this.options.limit); | ||
} | ||
if (this.options.offset) { | ||
if (this.options.offset !== undefined) { | ||
sql.offset(this.options.offset); | ||
@@ -331,0 +331,0 @@ } |
{ | ||
"name": "@knorm/postgres", | ||
"version": "1.1.1", | ||
"version": "1.1.2", | ||
"description": "Postgres plugin for knorm", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -516,2 +516,38 @@ const knorm = require('@knorm/knorm'); | ||
it('supports `limit: 0`', async () => { | ||
await new Query(User).insert([ | ||
{ id: 1, name: 'foo' }, | ||
{ id: 2, name: 'bar' } | ||
]); | ||
await expect( | ||
new Query(User).limit(0).fetch(), | ||
'to be fulfilled with value satisfying', | ||
[] | ||
); | ||
}); | ||
it('supports `offset: 0`', async () => { | ||
await new Query(User).insert([ | ||
{ id: 1, name: 'foo' }, | ||
{ id: 2, name: 'bar' } | ||
]); | ||
const spy = sinon.spy(Query.prototype, 'query'); | ||
await expect( | ||
new Query(User).offset(0).fetch(), | ||
'to be fulfilled with value satisfying', | ||
[{ id: 1, name: 'foo' }, { id: 2, name: 'bar' }] | ||
); | ||
await expect(spy, 'to have calls satisfying', () => { | ||
spy( | ||
expect.it( | ||
'when passed as parameter to', | ||
query => query.toString(), | ||
'to contain', | ||
'OFFSET 0' | ||
) | ||
); | ||
}); | ||
spy.restore(); | ||
}); | ||
it('adds `limit` for `fetch` when `first` is true', async () => { | ||
@@ -518,0 +554,0 @@ await new Query(User).insert({ id: 1, name: 'foo' }); |
75586
2007