node-firebird 1.1.2 → 1.1.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.
Files changed (2) hide show
  1. package/lib/index.js +40 -65
  2. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -3230,81 +3230,60 @@ function decodeResponse(data, callback, cnx, lowercase_keys, cb) {
3230
3230
  data.frows = data.frows || [];
3231
3231
 
3232
3232
  if (custom.asObject && !data.fcols) {
3233
- data.fcols = [];
3234
- for (var i = 0, length = output.length; i < length; i++) {
3235
- data.fcols.push(lowercase_keys ? output[i].alias.toLowerCase() : output[i].alias);
3233
+ if (lowercase_keys) {
3234
+ data.fcols = output.map((column) => column.alias.toLowerCase());
3235
+ } else {
3236
+ data.fcols = output.map((column) => column.alias);
3236
3237
  }
3237
3238
  }
3238
3239
 
3239
3240
  const arrBlob = [];
3241
+ const lowerV13 = statement.connection.accept.protocolVersion < PROTOCOL_VERSION13;
3240
3242
 
3241
3243
  while (data.fcount && (data.fstatus !== 100)) {
3242
- var lowerV13 = statement.connection.accept.protocolVersion < PROTOCOL_VERSION13;
3243
-
3244
- if (lowerV13) {
3245
- for (length = output.length; data.fcolumn < length; data.fcolumn++) {
3246
- item = output[data.fcolumn];
3247
-
3248
- try {
3249
- _xdrpos = data.pos;
3250
- const key = custom.asObject ? data.fcols[data.fcolumn] : data.fcolumn;
3251
- const row = data.frows.length;
3252
- let value = item.decode(data, lowerV13);
3253
- if (item.type === SQL_BLOB && value !== null) {
3254
- if (item.subType === isc_blob_text && cnx.options.blobAsText) {
3255
- value = fetch_blob_async_transaction(statement, value, key, row);
3256
- arrBlob.push(value);
3257
- } else {
3258
- value = fetch_blob_async(statement, value, key, row);
3259
- }
3260
- }
3261
- data.frow[key] = value;
3262
- } catch (e) {
3263
- // uncomplete packet read
3264
- data.pos = _xdrpos;
3265
- data.r = r;
3266
- return cb(new Error("Packet is not complete"));
3244
+ let nullBitSet;
3245
+ if (!lowerV13) {
3246
+ const nullBitsLen = Math.floor((output.length + 7) / 8);
3247
+ nullBitSet = new BitSet(data.readBuffer(nullBitsLen, false));
3248
+ data.readBuffer((4 - nullBitsLen) & 3, false); // Skip padding
3249
+ }
3250
+
3251
+ for (length = output.length; data.fcolumn < length; data.fcolumn++) {
3252
+ item = output[data.fcolumn];
3253
+
3254
+ if (!lowerV13 && nullBitSet.get(data.fcolumn)) {
3255
+ if (custom.asObject) {
3256
+ data.frow[data.fcols[data.fcolumn]] = null;
3257
+ } else {
3258
+ data.frow[data.fcolumn] = null;
3267
3259
  }
3268
3260
 
3261
+ continue;
3269
3262
  }
3270
- } else {
3271
- var nullBitsLen = Math.floor((output.length + 7) / 8);
3272
- var nullBitSet = new BitSet(data.readBuffer(nullBitsLen, false));
3273
- data.readBuffer((4 - nullBitsLen) & 3, false); // Skip padding
3274
3263
 
3275
- for (length = output.length; data.fcolumn < length; data.fcolumn++) {
3276
- item = output[data.fcolumn];
3264
+ try {
3265
+ _xdrpos = data.pos;
3266
+ const key = custom.asObject ? data.fcols[data.fcolumn] : data.fcolumn;
3267
+ const row = data.frows.length;
3268
+ let value = item.decode(data, lowerV13);
3277
3269
 
3278
- if (nullBitSet.get(data.fcolumn)) {
3279
- if (custom.asObject) {
3280
- data.frow[data.fcols[data.fcolumn]] = null;
3270
+ if (item.type === SQL_BLOB && value !== null) {
3271
+ if (item.subType === isc_blob_text && cnx.options.blobAsText) {
3272
+ value = fetch_blob_async_transaction(statement, value, key, row);
3273
+ arrBlob.push(value);
3281
3274
  } else {
3282
- data.frow[data.fcolumn] = null;
3275
+ value = fetch_blob_async(statement, value, key, row);
3283
3276
  }
3284
-
3285
- continue;
3286
3277
  }
3287
3278
 
3288
- try {
3289
- _xdrpos = data.pos;
3290
- var key = custom.asObject ? data.fcols[data.fcolumn] : data.fcolumn;
3291
- var value = item.decode(data, lowerV13);
3292
- if (item.type === SQL_BLOB && value !== null) {
3293
- if (item.subType === isc_blob_text && cnx.options.blobAsText) {
3294
- value = fetch_blob_async_transaction(statement, value, key, data);
3295
- arrBlob.push(value);
3296
- } else {
3297
- value = fetch_blob_async(statement, value, key);
3298
- }
3299
- }
3300
- data.frow[key] = value;
3301
- } catch (e) {
3302
- // uncomplete packet read
3303
- data.pos = _xdrpos;
3304
- data.r = r;
3305
- return cb(new Error("Packet is not complete"));
3306
- }
3279
+ data.frow[key] = value;
3280
+ } catch (e) {
3281
+ // uncomplete packet read
3282
+ data.pos = _xdrpos;
3283
+ data.r = r;
3284
+ return cb(new Error('Packet is not complete'));
3307
3285
  }
3286
+
3308
3287
  }
3309
3288
 
3310
3289
  data.fcolumn = 0;
@@ -4466,12 +4445,8 @@ Connection.prototype.sendExecute = function (op, statement, transaction, callbac
4466
4445
  this._queueEvent(callback);
4467
4446
  }
4468
4447
 
4469
- function fetch_blob_async_transaction(statement, id, name, row) {
4470
- const infoValue = {
4471
- row,
4472
- column: name,
4473
- value: ''
4474
- };
4448
+ function fetch_blob_async_transaction(statement, id, column, row) {
4449
+ const infoValue = { row, column, value: '' };
4475
4450
 
4476
4451
  return (transactionArg) => {
4477
4452
  const singleTransaction = transactionArg === undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-firebird",
3
- "version": "1.1.2",
3
+ "version": "1.1.3",
4
4
  "description": "Pure JavaScript and Asynchronous Firebird client for Node.js.",
5
5
  "keywords": [
6
6
  "firebird",