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 CHANGED
@@ -250,15 +250,25 @@ class DbClient extends EventEmitter {
250
250
 
251
251
  const executor = this.batch (options)
252
252
 
253
- return new Promise ((ok, fail) => {
253
+ try {
254
254
 
255
- statements.on ('error', fail)
256
- executor.on ('error', fail)
257
- executor.on ('close', ok)
255
+ await new Promise ((ok, fail) => {
258
256
 
259
- statements.pipe (executor)
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
- genColumnDefault (column) {
458
-
459
- const def = column.default;
460
-
461
- if (def === 'NULL' || def.indexOf ('(') !== -1) return def
457
+ * genColumnConstraints (column) {
462
458
 
463
- return this.quoteLiteral (def)
459
+ if (column.nullable === false) yield 'NOT NULL'
464
460
 
465
461
  }
466
462
 
467
- genColumnDefinition (column) {
463
+ genColumnDataType (column) {
468
464
 
469
- const {qName, typeDim, nullable} = column
465
+ return column.typeDim
470
466
 
471
- let s = qName + ' ' + typeDim
472
-
473
- if (column.default != null) s += ' DEFAULT ' + this.genColumnDefault (column)
467
+ }
474
468
 
475
- if (nullable === false) s += ' NOT NULL'
476
-
477
- return s
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
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "doix-db",
3
- "version": "1.0.71",
3
+ "version": "1.0.73",
4
4
  "description": "Shared database related code for doix",
5
5
  "main": "index.js",
6
6
  "files": [