node-firebird 1.1.10 → 2.0.0

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.
@@ -15,481 +15,490 @@ const
15
15
 
16
16
  //------------------------------------------------------
17
17
 
18
- function SQLVarText() {}
18
+ class SQLVarText {
19
+ decode(data, lowerV13) {
20
+ let ret;
21
+ if (this.subType > 1) {
22
+ // ToDo: with column charset
23
+ ret = data.readText(this.length, Const.DEFAULT_ENCODING);
24
+ } else if (this.subType === 0) {
25
+ // without charset definition
26
+ ret = data.readText(this.length, Const.DEFAULT_ENCODING);
27
+ } else {
28
+ ret = data.readBuffer(this.length);
29
+ }
19
30
 
20
- SQLVarText.prototype.decode = function(data, lowerV13) {
21
- let ret;
22
- if (this.subType > 1) {
23
- // ToDo: with column charset
24
- ret = data.readText(this.length, Const.DEFAULT_ENCODING);
25
- } else if (this.subType === 0) {
26
- // without charset definition
27
- ret = data.readText(this.length, Const.DEFAULT_ENCODING);
28
- } else {
29
- ret = data.readBuffer(this.length);
30
- }
31
+ if (!lowerV13 || !data.readInt()) {
32
+ return ret;
33
+ }
31
34
 
32
- if (!lowerV13 || !data.readInt()) {
33
- return ret;
35
+ return null;
34
36
  }
35
37
 
36
- return null;
37
- };
38
-
39
- SQLVarText.prototype.calcBlr = function(blr) {
40
- blr.addByte(Const.blr_text);
41
- blr.addWord(this.length);
42
- };
38
+ calcBlr(blr) {
39
+ blr.addByte(Const.blr_text);
40
+ blr.addWord(this.length);
41
+ }
42
+ }
43
43
 
44
44
  //------------------------------------------------------
45
45
 
46
- function SQLVarNull() {}
47
- SQLVarNull.prototype = new SQLVarText();
48
- SQLVarNull.prototype.constructor = SQLVarNull;
46
+ class SQLVarNull extends SQLVarText {
47
+ }
49
48
 
50
49
  //------------------------------------------------------
51
50
 
52
- function SQLVarString() {}
51
+ class SQLVarString {
52
+ decode(data, lowerV13) {
53
+ let ret;
54
+ if (this.subType > 1) {
55
+ // ToDo: with column charset
56
+ ret = data.readString(Const.DEFAULT_ENCODING);
57
+ } else if (this.subType === 0) {
58
+ // without charset definition
59
+ ret = data.readString(Const.DEFAULT_ENCODING);
60
+ } else {
61
+ ret = data.readBuffer();
62
+ }
53
63
 
54
- SQLVarString.prototype.decode = function(data, lowerV13) {
55
- let ret;
56
- if (this.subType > 1) {
57
- // ToDo: with column charset
58
- ret = data.readString(Const.DEFAULT_ENCODING);
59
- } else if (this.subType === 0) {
60
- // without charset definition
61
- ret = data.readString(Const.DEFAULT_ENCODING);
62
- } else {
63
- ret = data.readBuffer();
64
- }
64
+ if (!lowerV13 || !data.readInt()) {
65
+ return ret;
66
+ }
65
67
 
66
- if (!lowerV13 || !data.readInt()) {
67
- return ret;
68
+ return null;
68
69
  }
69
70
 
70
- return null;
71
- };
72
-
73
- SQLVarString.prototype.calcBlr = function(blr) {
74
- blr.addByte(Const.blr_varying);
75
- blr.addWord(this.length);
76
- };
71
+ calcBlr(blr) {
72
+ blr.addByte(Const.blr_varying);
73
+ blr.addWord(this.length);
74
+ }
75
+ }
77
76
 
78
77
  //------------------------------------------------------
79
78
 
80
- function SQLVarQuad() {}
79
+ class SQLVarQuad {
80
+ decode(data, lowerV13) {
81
+ var ret = data.readQuad();
81
82
 
82
- SQLVarQuad.prototype.decode = function(data, lowerV13) {
83
- var ret = data.readQuad();
84
-
85
- if (!lowerV13 || !data.readInt()) {
86
- return ret;
83
+ if (!lowerV13 || !data.readInt()) {
84
+ return ret;
85
+ }
86
+ return null;
87
87
  }
88
- return null;
89
- };
90
88
 
91
- SQLVarQuad.prototype.calcBlr = function(blr) {
92
- blr.addByte(Const.blr_quad);
93
- blr.addShort(this.scale);
94
- };
89
+ calcBlr(blr) {
90
+ blr.addByte(Const.blr_quad);
91
+ blr.addShort(this.scale);
92
+ }
93
+ }
95
94
 
96
95
  //------------------------------------------------------
97
96
 
98
- function SQLVarBlob() {}
99
- SQLVarBlob.prototype = new SQLVarQuad();
100
- SQLVarBlob.prototype.constructor = SQLVarBlob;
101
-
102
- SQLVarBlob.prototype.calcBlr = function(blr) {
103
- blr.addByte(Const.blr_quad);
104
- blr.addShort(0);
105
- };
97
+ class SQLVarBlob extends SQLVarQuad {
98
+ calcBlr(blr) {
99
+ blr.addByte(Const.blr_quad);
100
+ blr.addShort(0);
101
+ }
102
+ }
106
103
 
107
104
  //------------------------------------------------------
108
105
 
109
- function SQLVarArray() {}
110
- SQLVarArray.prototype = new SQLVarQuad();
111
- SQLVarArray.prototype.constructor = SQLVarArray;
112
-
113
- SQLVarArray.prototype.calcBlr = function(blr) {
114
- blr.addByte(Const.blr_quad);
115
- blr.addShort(0);
116
- };
106
+ class SQLVarArray extends SQLVarQuad {
107
+ calcBlr(blr) {
108
+ blr.addByte(Const.blr_quad);
109
+ blr.addShort(0);
110
+ }
111
+ }
117
112
 
118
113
  //------------------------------------------------------
119
114
 
120
- function SQLVarInt() {}
115
+ class SQLVarInt {
116
+ decode(data, lowerV13) {
117
+ var ret = data.readInt();
121
118
 
122
- SQLVarInt.prototype.decode = function(data, lowerV13) {
123
- var ret = data.readInt();
119
+ if (this.scale) {
120
+ ret = ret / ScaleDivisor[Math.abs(this.scale)];
121
+ }
124
122
 
125
- if (this.scale) {
126
- ret = ret / ScaleDivisor[Math.abs(this.scale)];
127
- }
123
+ if (!lowerV13 || !data.readInt()) {
124
+ return ret;
125
+ }
128
126
 
129
- if (!lowerV13 || !data.readInt()) {
130
- return ret;
127
+ return null;
131
128
  }
132
129
 
133
- return null;
134
- };
135
-
136
- SQLVarInt.prototype.calcBlr = function(blr) {
137
- blr.addByte(Const.blr_long);
138
- blr.addShort(this.scale);
139
- };
130
+ calcBlr(blr) {
131
+ blr.addByte(Const.blr_long);
132
+ blr.addShort(this.scale);
133
+ }
134
+ }
140
135
 
141
136
  //------------------------------------------------------
142
137
 
143
- function SQLVarShort() {}
144
- SQLVarShort.prototype = new SQLVarInt();
145
- SQLVarShort.prototype.constructor = SQLVarShort;
146
-
147
- SQLVarShort.prototype.calcBlr = function(blr) {
148
- blr.addByte(Const.blr_short);
149
- blr.addShort(this.scale);
150
- };
138
+ class SQLVarShort extends SQLVarInt {
139
+ calcBlr(blr) {
140
+ blr.addByte(Const.blr_short);
141
+ blr.addShort(this.scale);
142
+ }
143
+ }
151
144
 
152
145
  //------------------------------------------------------
153
146
 
154
- function SQLVarInt64() {}
147
+ class SQLVarInt64 {
148
+ decode(data, lowerV13) {
149
+ var ret = data.readInt64();
155
150
 
156
- SQLVarInt64.prototype.decode = function(data, lowerV13) {
157
- var ret = data.readInt64();
151
+ if (this.scale) {
152
+ ret = ret / ScaleDivisor[Math.abs(this.scale)];
153
+ }
158
154
 
159
- if (this.scale) {
160
- ret = ret / ScaleDivisor[Math.abs(this.scale)];
155
+ if (!lowerV13 || !data.readInt()) {
156
+ return ret;
157
+ }
158
+ return null;
161
159
  }
162
160
 
163
- if (!lowerV13 || !data.readInt()) {
164
- return ret;
161
+ calcBlr(blr) {
162
+ blr.addByte(Const.blr_int64);
163
+ blr.addShort(this.scale);
165
164
  }
166
- return null;
167
- };
168
-
169
- SQLVarInt64.prototype.calcBlr = function(blr) {
170
- blr.addByte(Const.blr_int64);
171
- blr.addShort(this.scale);
172
- };
165
+ }
173
166
 
174
167
  //------------------------------------------------------
175
168
 
176
- function SQLVarInt128() {}
169
+ class SQLVarInt128 {
170
+ decode(data, lowerV13) {
171
+ var retBigInt = BigInt(data.readInt128())
177
172
 
178
- SQLVarInt128.prototype.decode = function (data, lowerV13) {
179
- var retBigInt = BigInt(data.readInt128())
173
+ if (retBigInt > BigInt(Number.MAX_SAFE_INTEGER)) {
174
+ var ret = retBigInt.toString();
180
175
 
181
- if (retBigInt > BigInt(Number.MAX_SAFE_INTEGER)) {
182
- var ret = retBigInt.toString();
176
+ var integerPart = ret.slice(0, Math.abs(this.scale) * -1)
177
+ var decimalPart = ret.slice(Math.abs(this.scale) * -1)
183
178
 
184
- var integerPart = ret.slice(0, Math.abs(this.scale) * -1)
185
- var decimalPart = ret.slice(Math.abs(this.scale) * -1)
179
+ if (integerPart === '') integerPart = '0'
186
180
 
187
- if (integerPart === '') integerPart = '0'
181
+ ret = `${integerPart}.${decimalPart}`
182
+ } else {
183
+ var ret = Number(retBigInt);
184
+ ret = ret / ScaleDivisor[Math.abs(this.scale)];
185
+ }
188
186
 
189
- ret = `${integerPart}.${decimalPart}`
190
- } else {
191
- var ret = Number(retBigInt);
192
- ret = ret / ScaleDivisor[Math.abs(this.scale)];
193
- }
187
+ if (!lowerV13 || !data.readInt()) {
188
+ return ret;
189
+ }
194
190
 
195
- if (!lowerV13 || !data.readInt()) {
196
- return ret;
191
+ return null;
197
192
  }
198
193
 
199
- return null;
200
- };
201
-
202
- SQLVarInt128.prototype.calcBlr = function (blr) {
203
- blr.addByte(Const.blr_int128);
204
- blr.addShort(this.scale);
205
- };
194
+ calcBlr(blr) {
195
+ blr.addByte(Const.blr_int128);
196
+ blr.addShort(this.scale);
197
+ }
198
+ }
206
199
 
207
200
  //------------------------------------------------------
208
201
 
209
- function SQLVarFloat() { }
202
+ class SQLVarFloat {
203
+ decode(data, lowerV13) {
204
+ var ret = data.readFloat();
210
205
 
211
- SQLVarFloat.prototype.decode = function(data, lowerV13) {
212
- var ret = data.readFloat();
206
+ if (!lowerV13 || !data.readInt()) {
207
+ return ret;
208
+ }
213
209
 
214
- if (!lowerV13 || !data.readInt()) {
215
- return ret;
210
+ return null;
216
211
  }
217
212
 
218
- return null;
219
- };
220
-
221
- SQLVarFloat.prototype.calcBlr = function(blr) {
222
- blr.addByte(Const.blr_float);
223
- };
213
+ calcBlr(blr) {
214
+ blr.addByte(Const.blr_float);
215
+ }
216
+ }
224
217
 
225
218
  //------------------------------------------------------
226
219
 
227
- function SQLVarDouble() {}
220
+ class SQLVarDouble {
221
+ decode(data, lowerV13) {
222
+ var ret = data.readDouble();
228
223
 
229
- SQLVarDouble.prototype.decode = function(data, lowerV13) {
230
- var ret = data.readDouble();
224
+ if (!lowerV13 || !data.readInt()) {
225
+ return ret;
226
+ }
231
227
 
232
- if (!lowerV13 || !data.readInt()) {
233
- return ret;
228
+ return null;
234
229
  }
235
230
 
236
- return null;
237
- };
238
-
239
- SQLVarDouble.prototype.calcBlr = function(blr) {
240
- blr.addByte(Const.blr_double);
241
- };
231
+ calcBlr(blr) {
232
+ blr.addByte(Const.blr_double);
233
+ }
234
+ }
242
235
 
243
236
  //------------------------------------------------------
244
237
 
245
- function SQLVarDate() {}
238
+ class SQLVarDate {
239
+ decode(data, lowerV13) {
240
+ var ret = data.readInt();
246
241
 
247
- SQLVarDate.prototype.decode = function(data, lowerV13) {
248
- var ret = data.readInt();
242
+ if (!lowerV13 || !data.readInt()) {
243
+ var d = new Date(0);
244
+ d.setMilliseconds((ret - DateOffset) * TimeCoeff + d.getTimezoneOffset() * MsPerMinute);
245
+ return d;
246
+ }
249
247
 
250
- if (!lowerV13 || !data.readInt()) {
251
- var d = new Date(0);
252
- d.setMilliseconds((ret - DateOffset) * TimeCoeff + d.getTimezoneOffset() * MsPerMinute);
253
- return d;
248
+ return null;
254
249
  }
255
250
 
256
- return null;
257
- };
258
-
259
- SQLVarDate.prototype.calcBlr = function(blr) {
260
- blr.addByte(Const.blr_sql_date);
261
- };
251
+ calcBlr(blr) {
252
+ blr.addByte(Const.blr_sql_date);
253
+ }
254
+ }
262
255
 
263
256
  //------------------------------------------------------
264
257
 
265
- function SQLVarTime() {}
266
-
267
- SQLVarTime.prototype.decode = function(data, lowerV13) {
268
- var ret = data.readUInt();
258
+ class SQLVarTime {
259
+ decode(data, lowerV13) {
260
+ var ret = data.readUInt();
269
261
 
270
- if (!lowerV13 || !data.readInt()) {
271
- var d = new Date(0);
272
- d.setMilliseconds(Math.floor(ret / 10) + d.getTimezoneOffset() * MsPerMinute);
273
- return d;
262
+ if (!lowerV13 || !data.readInt()) {
263
+ var d = new Date(0);
264
+ d.setMilliseconds(Math.floor(ret / 10) + d.getTimezoneOffset() * MsPerMinute);
265
+ return d;
266
+ }
267
+ return null;
274
268
  }
275
- return null;
276
- };
277
269
 
278
- SQLVarTime.prototype.calcBlr = function(blr) {
279
- blr.addByte(Const.blr_sql_time);
280
- };
270
+ calcBlr(blr) {
271
+ blr.addByte(Const.blr_sql_time);
272
+ }
273
+ }
281
274
 
282
275
  //------------------------------------------------------
283
276
 
284
- function SQLVarTimeStamp() {}
277
+ class SQLVarTimeStamp {
278
+ decode(data, lowerV13) {
279
+ var date = data.readInt();
280
+ var time = data.readUInt();
285
281
 
286
- SQLVarTimeStamp.prototype.decode = function(data, lowerV13) {
287
- var date = data.readInt();
288
- var time = data.readUInt();
282
+ if (!lowerV13 || !data.readInt()) {
283
+ var d = new Date(0);
284
+ d.setMilliseconds((date - DateOffset) * TimeCoeff + Math.floor(time / 10) + d.getTimezoneOffset() * MsPerMinute);
285
+ return d;
286
+ }
289
287
 
290
- if (!lowerV13 || !data.readInt()) {
291
- var d = new Date(0);
292
- d.setMilliseconds((date - DateOffset) * TimeCoeff + Math.floor(time / 10) + d.getTimezoneOffset() * MsPerMinute);
293
- return d;
288
+ return null;
294
289
  }
295
290
 
296
- return null;
297
- };
298
-
299
- SQLVarTimeStamp.prototype.calcBlr = function(blr) {
300
- blr.addByte(Const.blr_timestamp);
301
- };
291
+ calcBlr(blr) {
292
+ blr.addByte(Const.blr_timestamp);
293
+ }
294
+ }
302
295
 
303
296
  //------------------------------------------------------
304
297
 
305
- function SQLVarBoolean() {}
306
-
307
- SQLVarBoolean.prototype.decode = function(data, lowerV13) {
308
- var ret = data.readInt();
298
+ class SQLVarBoolean {
299
+ decode(data, lowerV13) {
300
+ var ret = data.readInt();
309
301
 
310
- if (!lowerV13 || !data.readInt()) {
311
- return Boolean(ret);
302
+ if (!lowerV13 || !data.readInt()) {
303
+ return Boolean(ret);
304
+ }
305
+ return null;
312
306
  }
313
- return null;
314
- };
315
307
 
316
- SQLVarBoolean.prototype.calcBlr = function(blr) {
317
- blr.addByte(Const.blr_bool);
318
- };
308
+ calcBlr(blr) {
309
+ blr.addByte(Const.blr_bool);
310
+ }
311
+ }
319
312
 
320
313
  //------------------------------------------------------
321
314
 
322
- function SQLParamInt(value){
323
- this.value = value;
324
- }
315
+ class SQLParamInt {
316
+ constructor(value) {
317
+ this.value = value;
318
+ }
325
319
 
326
- SQLParamInt.prototype.calcBlr = function(blr) {
327
- blr.addByte(Const.blr_long);
328
- blr.addShort(0);
329
- };
320
+ calcBlr(blr) {
321
+ blr.addByte(Const.blr_long);
322
+ blr.addShort(0);
323
+ }
330
324
 
331
- SQLParamInt.prototype.encode = function(data) {
332
- if (this.value != null) {
333
- data.addInt(this.value);
334
- } else {
335
- data.addInt(0);
336
- data.addInt(1);
325
+ encode(data) {
326
+ if (this.value != null) {
327
+ data.addInt(this.value);
328
+ } else {
329
+ data.addInt(0);
330
+ data.addInt(1);
331
+ }
337
332
  }
338
- };
333
+ }
339
334
 
340
335
  //------------------------------------------------------
341
336
 
342
- function SQLParamInt64(value){
343
- this.value = value;
344
- }
337
+ class SQLParamInt64 {
338
+ constructor(value) {
339
+ this.value = value;
340
+ }
345
341
 
346
- SQLParamInt64.prototype.calcBlr = function(blr) {
347
- blr.addByte(Const.blr_int64);
348
- blr.addShort(0);
349
- };
342
+ calcBlr(blr) {
343
+ blr.addByte(Const.blr_int64);
344
+ blr.addShort(0);
345
+ }
350
346
 
351
- SQLParamInt64.prototype.encode = function(data) {
352
- if (this.value != null) {
353
- data.addInt64(this.value);
354
- } else {
355
- data.addInt64(0);
356
- data.addInt(1);
347
+ encode(data) {
348
+ if (this.value != null) {
349
+ data.addInt64(this.value);
350
+ } else {
351
+ data.addInt64(0);
352
+ data.addInt(1);
353
+ }
357
354
  }
358
- };
355
+ }
359
356
 
360
357
  //------------------------------------------------------
361
358
 
362
- function SQLParamInt128(value) {
363
- this.value = value;
364
- }
359
+ class SQLParamInt128 {
360
+ constructor(value) {
361
+ this.value = value;
362
+ }
365
363
 
366
- SQLParamInt128.prototype.calcBlr = function (blr) {
367
- blr.addByte(Const.blr_int128);
368
- blr.addShort(0);
369
- };
364
+ calcBlr(blr) {
365
+ blr.addByte(Const.blr_int128);
366
+ blr.addShort(0);
367
+ }
370
368
 
371
- SQLParamInt128.prototype.encode = function (data) {
372
- if (this.value != null) {
373
- data.addInt128(this.value);
374
- } else {
375
- data.addInt128(0);
376
- data.addInt(1);
369
+ encode(data) {
370
+ if (this.value != null) {
371
+ data.addInt128(this.value);
372
+ } else {
373
+ data.addInt128(0);
374
+ data.addInt(1);
375
+ }
377
376
  }
378
- };
377
+ }
379
378
 
380
379
  //------------------------------------------------------
381
380
 
382
- function SQLParamDouble(value) {
383
- this.value = value;
384
- }
381
+ class SQLParamDouble {
382
+ constructor(value) {
383
+ this.value = value;
384
+ }
385
385
 
386
- SQLParamDouble.prototype.encode = function(data) {
387
- if (this.value != null) {
388
- data.addDouble(this.value);
389
- } else {
390
- data.addDouble(0);
391
- data.addInt(1);
386
+ encode(data) {
387
+ if (this.value != null) {
388
+ data.addDouble(this.value);
389
+ } else {
390
+ data.addDouble(0);
391
+ data.addInt(1);
392
+ }
392
393
  }
393
- };
394
394
 
395
- SQLParamDouble.prototype.calcBlr = function(blr) {
396
- blr.addByte(Const.blr_double);
397
- };
395
+ calcBlr(blr) {
396
+ blr.addByte(Const.blr_double);
397
+ }
398
+ }
398
399
 
399
400
  //------------------------------------------------------
400
401
 
401
- function SQLParamString(value) {
402
- this.value = value;
403
- }
402
+ class SQLParamString {
403
+ constructor(value) {
404
+ this.value = value;
405
+ }
404
406
 
405
- SQLParamString.prototype.encode = function(data) {
406
- if (this.value != null) {
407
- data.addText(this.value, Const.DEFAULT_ENCODING);
408
- } else {
409
- data.addInt(1);
407
+ encode(data) {
408
+ if (this.value != null) {
409
+ data.addText(this.value, Const.DEFAULT_ENCODING);
410
+ } else {
411
+ data.addInt(1);
412
+ }
410
413
  }
411
- };
412
414
 
413
- SQLParamString.prototype.calcBlr = function(blr) {
414
- blr.addByte(Const.blr_text);
415
- var len = this.value ? Buffer.byteLength(this.value, Const.DEFAULT_ENCODING) : 0;
416
- blr.addWord(len);
417
- };
415
+ calcBlr(blr) {
416
+ blr.addByte(Const.blr_text);
417
+ var len = this.value ? Buffer.byteLength(this.value, Const.DEFAULT_ENCODING) : 0;
418
+ blr.addWord(len);
419
+ }
420
+ }
418
421
 
419
422
  //------------------------------------------------------
420
423
 
421
- function SQLParamQuad(value) {
422
- this.value = value;
423
- }
424
-
425
- SQLParamQuad.prototype.encode = function(data) {
426
- if (this.value != null) {
427
- data.addInt(this.value.high);
428
- data.addInt(this.value.low);
429
- } else {
430
- data.addInt(0);
431
- data.addInt(0);
432
- data.addInt(1);
424
+ class SQLParamQuad {
425
+ constructor(value) {
426
+ this.value = value;
433
427
  }
434
- };
435
-
436
- SQLParamQuad.prototype.calcBlr = function(blr) {
437
- blr.addByte(Const.blr_quad);
438
- blr.addShort(0);
439
- };
440
428
 
441
- //------------------------------------------------------
429
+ encode(data) {
430
+ if (this.value != null) {
431
+ data.addInt(this.value.high);
432
+ data.addInt(this.value.low);
433
+ } else {
434
+ data.addInt(0);
435
+ data.addInt(0);
436
+ data.addInt(1);
437
+ }
438
+ }
442
439
 
443
- function SQLParamDate(value) {
444
- this.value = value;
440
+ calcBlr(blr) {
441
+ blr.addByte(Const.blr_quad);
442
+ blr.addShort(0);
443
+ }
445
444
  }
446
445
 
447
- SQLParamDate.prototype.encode = function(data) {
448
- if (this.value != null) {
446
+ //------------------------------------------------------
449
447
 
450
- var value = this.value.getTime() - this.value.getTimezoneOffset() * MsPerMinute;
451
- var time = value % TimeCoeff;
452
- var date = (value - time) / TimeCoeff + DateOffset;
453
- time *= 10;
448
+ class SQLParamDate {
449
+ constructor(value) {
450
+ this.value = value;
451
+ }
454
452
 
455
- // check overflow
456
- if (time < 0) {
457
- date--;
458
- time = TimeCoeff*10 + time;
453
+ encode(data) {
454
+ if (this.value != null) {
455
+
456
+ var value = this.value.getTime() - this.value.getTimezoneOffset() * MsPerMinute;
457
+ var time = value % TimeCoeff;
458
+ var date = (value - time) / TimeCoeff + DateOffset;
459
+ time *= 10;
460
+
461
+ // check overflow
462
+ if (time < 0) {
463
+ date--;
464
+ time = TimeCoeff*10 + time;
465
+ }
466
+
467
+ data.addInt(date);
468
+ data.addUInt(time);
469
+ } else {
470
+ data.addInt(0);
471
+ data.addUInt(0);
472
+ data.addInt(1);
459
473
  }
460
-
461
- data.addInt(date);
462
- data.addUInt(time);
463
- } else {
464
- data.addInt(0);
465
- data.addUInt(0);
466
- data.addInt(1);
467
474
  }
468
- };
469
475
 
470
- SQLParamDate.prototype.calcBlr = function(blr) {
471
- blr.addByte(Const.blr_timestamp);
472
- };
476
+ calcBlr(blr) {
477
+ blr.addByte(Const.blr_timestamp);
478
+ }
479
+ }
473
480
 
474
481
  //------------------------------------------------------
475
482
 
476
- function SQLParamBool(value) {
477
- this.value = value;
478
- }
483
+ class SQLParamBool {
484
+ constructor(value) {
485
+ this.value = value;
486
+ }
479
487
 
480
- SQLParamBool.prototype.encode = function(data) {
481
- if (this.value != null) {
482
- data.addInt(this.value ? 1 : 0);
483
- } else {
484
- data.addInt(0);
485
- data.addInt(1);
488
+ encode(data) {
489
+ if (this.value != null) {
490
+ data.addInt(this.value ? 1 : 0);
491
+ } else {
492
+ data.addInt(0);
493
+ data.addInt(1);
494
+ }
486
495
  }
487
- };
488
496
 
489
- SQLParamBool.prototype.calcBlr = function(blr) {
490
- blr.addByte(Const.blr_short);
491
- blr.addShort(0);
492
- };
497
+ calcBlr(blr) {
498
+ blr.addByte(Const.blr_short);
499
+ blr.addShort(0);
500
+ }
501
+ }
493
502
 
494
503
  module.exports = {
495
504
  SQLVarArray,