@bdkinc/knex-ibmi 0.3.1 → 0.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +7 -11
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -452,32 +452,28 @@ var DB2Client = class extends import_knex.knex.Client {
|
|
|
452
452
|
_stream(connection, obj, stream, options) {
|
|
453
453
|
if (!obj.sql) throw new Error("A query is required to stream results");
|
|
454
454
|
return new Promise(async (resolve, reject) => {
|
|
455
|
-
stream.on("error",
|
|
456
|
-
if (err) {
|
|
457
|
-
connection.__knex__disposed = err;
|
|
458
|
-
}
|
|
459
|
-
reject(err);
|
|
460
|
-
});
|
|
455
|
+
stream.on("error", reject);
|
|
461
456
|
stream.on("end", resolve);
|
|
457
|
+
const cursor = await connection.query(obj.sql, obj.bindings, {
|
|
458
|
+
cursor: true,
|
|
459
|
+
fetchSize: options?.fetchSize || 1
|
|
460
|
+
});
|
|
462
461
|
const readableStream = new import_node_stream.Readable({
|
|
463
462
|
objectMode: true,
|
|
464
463
|
async read() {
|
|
465
|
-
const cursor = await connection.query(obj.sql, obj.bindings, {
|
|
466
|
-
cursor: true,
|
|
467
|
-
fetchSize: options?.fetchSize || 1
|
|
468
|
-
});
|
|
469
464
|
while (!cursor.noData) {
|
|
470
465
|
const result = await cursor.fetch();
|
|
471
466
|
this.push(result);
|
|
472
467
|
}
|
|
468
|
+
this.push(null);
|
|
473
469
|
await cursor.close();
|
|
474
470
|
}
|
|
475
471
|
});
|
|
476
|
-
readableStream.pipe(stream);
|
|
477
472
|
readableStream.on("error", (err) => {
|
|
478
473
|
reject(err);
|
|
479
474
|
stream.emit("error", err);
|
|
480
475
|
});
|
|
476
|
+
readableStream.pipe(stream);
|
|
481
477
|
});
|
|
482
478
|
}
|
|
483
479
|
transaction(container, config, outerTx) {
|