Skip to content

Commit 9f663a3

Browse files
committed
...
1 parent 8ea68e8 commit 9f663a3

1 file changed

Lines changed: 15 additions & 3 deletions

File tree

src/query-builder/insert-query-builder.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ import { Selectable } from '../util/column-type.js'
5353
import { Explainable, ExplainFormat } from '../util/explainable.js'
5454
import { Expression } from '../expression/expression.js'
5555
import { KyselyTypeError } from '../util/type-error.js'
56-
import { Streamable } from '../util/streamable.js'
56+
import { Streamable, StreamOptions } from '../util/streamable.js'
5757
import { parseTop } from '../parser/top-parser.js'
5858
import {
5959
OutputCallback,
@@ -1347,10 +1347,22 @@ export class InsertQueryBuilder<DB, TB extends keyof DB, O>
13471347
return result as never
13481348
}
13491349

1350-
async *stream(chunkSize: number = 100): AsyncIterableIterator<O> {
1350+
async *stream(
1351+
chunkSizeOrOptions?: StreamOptions | StreamOptions['chunkSize'],
1352+
): AsyncIterableIterator<O> {
1353+
if (typeof chunkSizeOrOptions !== 'object') {
1354+
chunkSizeOrOptions = {
1355+
chunkSize: chunkSizeOrOptions,
1356+
}
1357+
}
1358+
13511359
const compiledQuery = this.compile()
13521360

1353-
const stream = this.#props.executor.stream<O>(compiledQuery, chunkSize)
1361+
const stream = this.#props.executor.stream<O>(
1362+
compiledQuery,
1363+
chunkSizeOrOptions.chunkSize ?? 100,
1364+
chunkSizeOrOptions,
1365+
)
13541366

13551367
for await (const item of stream) {
13561368
yield* item.rows

0 commit comments

Comments
 (0)