Test limits
This commit is contained in:
parent
9a2eaaad42
commit
348b06948b
|
@ -495,13 +495,15 @@ export class QueryBuilder<T> {
|
||||||
|
|
||||||
this.excludeDocs()
|
this.excludeDocs()
|
||||||
let skipRemaining = skip
|
let skipRemaining = skip
|
||||||
|
let iterationFetched = 0
|
||||||
do {
|
do {
|
||||||
const toSkip = Math.min(QueryBuilder.maxLimit, skipRemaining)
|
const toSkip = Math.min(QueryBuilder.maxLimit, skipRemaining)
|
||||||
this.setLimit(toSkip)
|
this.setLimit(toSkip)
|
||||||
const { bookmark, rows } = await this.#execute()
|
const { bookmark, rows } = await this.#execute()
|
||||||
this.setBookmark(bookmark)
|
this.setBookmark(bookmark)
|
||||||
|
iterationFetched = rows.length
|
||||||
skipRemaining -= rows.length
|
skipRemaining -= rows.length
|
||||||
} while (skipRemaining > 0)
|
} while (skipRemaining > 0 && iterationFetched > 0)
|
||||||
|
|
||||||
this.#includeDocs = prevIncludeDocs
|
this.#includeDocs = prevIncludeDocs
|
||||||
this.#limit = prevLimit
|
this.#limit = prevLimit
|
||||||
|
|
|
@ -210,6 +210,17 @@ describe("lucene", () => {
|
||||||
docs.slice(skip, skip + resp.rows.length).map(expect.objectContaining)
|
docs.slice(skip, skip + resp.rows.length).map(expect.objectContaining)
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it("should not return results if skipping all docs", async () => {
|
||||||
|
const builder = new QueryBuilder(skipDbName, INDEX_NAME)
|
||||||
|
// Skipping 2 max limits plus a little bit more
|
||||||
|
const skip = docs.length + 1
|
||||||
|
builder.setSkip(skip)
|
||||||
|
|
||||||
|
const resp = await builder.run()
|
||||||
|
|
||||||
|
expect(resp.rows.length).toBe(0)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue