@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.
Files changed (2) hide show
  1. package/dist/index.js +34 -26
  2. 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(async (resolve, reject) => {
454
+ return new Promise((resolve, reject) => {
455
455
  stream.on("error", reject);
456
456
  stream.on("end", resolve);
457
- const cursor = await connection.query(obj.sql, obj.bindings, {
458
- cursor: true,
459
- fetchSize: options?.fetchSize || 1
460
- });
461
- const readableStream = new import_node_stream.Readable({
462
- objectMode: true,
463
- read() {
464
- cursor.fetch((error, result) => {
465
- if (error) {
466
- console.log(error);
467
- return;
468
- }
469
- if (!cursor.noData) {
470
- this.push(result);
471
- } else {
472
- result && Array.isArray(result) ? this.push(result) : this.push(null);
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
- console.log(error2);
476
- return;
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) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bdkinc/knex-ibmi",
3
- "version": "0.3.9",
3
+ "version": "0.3.11",
4
4
  "description": "Knex dialect for IBMi",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",