doix-db 1.0.71 → 1.0.73
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/lib/DbClient.js +16 -6
- package/lib/DbLang.js +26 -14
- package/package.json +1 -1
package/lib/DbClient.js
CHANGED
|
@@ -250,15 +250,25 @@ class DbClient extends EventEmitter {
|
|
|
250
250
|
|
|
251
251
|
const executor = this.batch (options)
|
|
252
252
|
|
|
253
|
-
|
|
253
|
+
try {
|
|
254
254
|
|
|
255
|
-
|
|
256
|
-
executor.on ('error', fail)
|
|
257
|
-
executor.on ('close', ok)
|
|
255
|
+
await new Promise ((ok, fail) => {
|
|
258
256
|
|
|
259
|
-
|
|
257
|
+
statements.on ('error', fail)
|
|
258
|
+
executor.on ('error', fail)
|
|
259
|
+
executor.on ('close', ok)
|
|
260
|
+
|
|
261
|
+
statements.pipe (executor)
|
|
262
|
+
|
|
263
|
+
})
|
|
264
|
+
|
|
260
265
|
|
|
261
|
-
}
|
|
266
|
+
}
|
|
267
|
+
catch (cause) {
|
|
268
|
+
|
|
269
|
+
throw Error (cause.message, {cause})
|
|
270
|
+
|
|
271
|
+
}
|
|
262
272
|
|
|
263
273
|
}
|
|
264
274
|
|
package/lib/DbLang.js
CHANGED
|
@@ -454,27 +454,39 @@ class DbLang {
|
|
|
454
454
|
|
|
455
455
|
}
|
|
456
456
|
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
const def = column.default;
|
|
460
|
-
|
|
461
|
-
if (def === 'NULL' || def.indexOf ('(') !== -1) return def
|
|
457
|
+
* genColumnConstraints (column) {
|
|
462
458
|
|
|
463
|
-
|
|
459
|
+
if (column.nullable === false) yield 'NOT NULL'
|
|
464
460
|
|
|
465
461
|
}
|
|
466
462
|
|
|
467
|
-
|
|
463
|
+
genColumnDataType (column) {
|
|
468
464
|
|
|
469
|
-
|
|
465
|
+
return column.typeDim
|
|
470
466
|
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
if (column.default != null) s += ' DEFAULT ' + this.genColumnDefault (column)
|
|
467
|
+
}
|
|
474
468
|
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
469
|
+
* genColumnDefinitionParts (column) {
|
|
470
|
+
|
|
471
|
+
yield column.qName
|
|
472
|
+
|
|
473
|
+
yield this.genColumnDataType (column)
|
|
474
|
+
|
|
475
|
+
{
|
|
476
|
+
|
|
477
|
+
const def = column.default
|
|
478
|
+
|
|
479
|
+
if (def) yield 'DEFAULT ' + def
|
|
480
|
+
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
for (const c of this.genColumnConstraints (column)) yield c
|
|
484
|
+
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
genColumnDefinition (column) {
|
|
488
|
+
|
|
489
|
+
return [...this.genColumnDefinitionParts (column)].join (' ')
|
|
478
490
|
|
|
479
491
|
}
|
|
480
492
|
|