@bdkinc/knex-ibmi 0.3.9 → 0.3.11
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 +34 -26
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -451,40 +451,48 @@ var DB2Client = class extends import_knex.knex.Client {
|
|
|
451
451
|
}
|
|
452
452
|
async _stream(connection, obj, stream, options) {
|
|
453
453
|
if (!obj.sql) throw new Error("A query is required to stream results");
|
|
454
|
-
return new Promise(
|
|
454
|
+
return new Promise((resolve, reject) => {
|
|
455
455
|
stream.on("error", reject);
|
|
456
456
|
stream.on("end", resolve);
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
cursor.close((error2) => {
|
|
457
|
+
connection.query(
|
|
458
|
+
obj.sql,
|
|
459
|
+
obj.bindings,
|
|
460
|
+
{
|
|
461
|
+
cursor: true,
|
|
462
|
+
fetchSize: options?.fetchSize || 1
|
|
463
|
+
},
|
|
464
|
+
(error, cursor) => {
|
|
465
|
+
const printError = this.printError;
|
|
466
|
+
if (error) {
|
|
467
|
+
this.printError(JSON.stringify(error, null, 2));
|
|
468
|
+
}
|
|
469
|
+
const readableStream = new import_node_stream.Readable({
|
|
470
|
+
objectMode: true,
|
|
471
|
+
read() {
|
|
472
|
+
cursor.fetch((error2, result) => {
|
|
474
473
|
if (error2) {
|
|
475
|
-
|
|
476
|
-
|
|
474
|
+
printError(JSON.stringify(error2, null, 2));
|
|
475
|
+
}
|
|
476
|
+
if (!cursor.noData) {
|
|
477
|
+
this.push(result);
|
|
478
|
+
} else {
|
|
479
|
+
this.push(null);
|
|
480
|
+
cursor.close((error3) => {
|
|
481
|
+
if (error3) {
|
|
482
|
+
printError(JSON.stringify(error3, null, 2));
|
|
483
|
+
}
|
|
484
|
+
});
|
|
477
485
|
}
|
|
478
486
|
});
|
|
479
487
|
}
|
|
480
488
|
});
|
|
489
|
+
readableStream.on("error", (err) => {
|
|
490
|
+
reject(err);
|
|
491
|
+
stream.emit("error", err);
|
|
492
|
+
});
|
|
493
|
+
readableStream.pipe(stream);
|
|
481
494
|
}
|
|
482
|
-
|
|
483
|
-
readableStream.on("error", (err) => {
|
|
484
|
-
reject(err);
|
|
485
|
-
stream.emit("error", err);
|
|
486
|
-
});
|
|
487
|
-
readableStream.pipe(stream);
|
|
495
|
+
);
|
|
488
496
|
});
|
|
489
497
|
}
|
|
490
498
|
transaction(container, config, outerTx) {
|