@bdkinc/knex-ibmi 0.3.3 → 0.3.5

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/README.md CHANGED
@@ -208,7 +208,7 @@ try {
208
208
 
209
209
  await finished(data); // db queries are promises, we need to wait until resolved
210
210
 
211
- // or we can iterate through each record one at a time (fetchSize has no effect)
211
+ // or we can iterate through each record
212
212
  for await (const record of data) {
213
213
  console.log(record);
214
214
  }
package/dist/index.js CHANGED
@@ -449,7 +449,7 @@ var DB2Client = class extends import_knex.knex.Client {
449
449
  this.printDebug(obj);
450
450
  return obj;
451
451
  }
452
- _stream(connection, obj, stream, options) {
452
+ async _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
455
  stream.on("error", reject);
@@ -460,13 +460,23 @@ var DB2Client = class extends import_knex.knex.Client {
460
460
  });
461
461
  const readableStream = new import_node_stream.Readable({
462
462
  objectMode: true,
463
- async read() {
464
- while (!cursor.noData) {
465
- const result = await cursor.fetch();
466
- this.push(result);
467
- }
468
- this.push(null);
469
- await cursor.close();
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
+ cursor.close((error2) => {
473
+ if (error2) {
474
+ console.log(error2);
475
+ return;
476
+ }
477
+ });
478
+ }
479
+ });
470
480
  }
471
481
  });
472
482
  readableStream.on("error", (err) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bdkinc/knex-ibmi",
3
- "version": "0.3.3",
3
+ "version": "0.3.5",
4
4
  "description": "Knex dialect for IBMi",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",