doix-db 1.0.43 → 1.0.46

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
@@ -293,7 +293,7 @@ class DbClient extends EventEmitter {
293
293
 
294
294
  const sql = params.pop ()
295
295
 
296
- await this.do (sql, params)
296
+ return this.do (sql, params)
297
297
 
298
298
  }
299
299
 
package/lib/DbLang.js CHANGED
@@ -498,6 +498,12 @@ class DbLang {
498
498
 
499
499
  }
500
500
 
501
+ wrapViewSql (view) {
502
+
503
+ view.sql = `SELECT ${Object.values (view.columns).map (i => i.qName)} FROM (${view.sql}) t`
504
+
505
+ }
506
+
501
507
  normalizeSQL (call) {
502
508
 
503
509
  call.sql = call.sql.trim ()
@@ -6,9 +6,25 @@ class DbView extends DbRelation {
6
6
 
7
7
  super (o)
8
8
 
9
+ this.rawSql = this.sql
10
+
9
11
  for (const k of ['options', 'specification']) if (!(k in o)) this [k] = ''
12
+
13
+ if (!('wrap' in this)) this.wrap = false
14
+
15
+ if (typeof this.wrap !== 'boolean') throw Error (`${this.name}: wrap option must be boolean`)
16
+
10
17
 
11
18
  }
19
+
20
+ setLang (lang) {
21
+
22
+ super.setLang (lang)
23
+
24
+ if (this.wrap) lang.wrapViewSql (this)
25
+
26
+ }
27
+
12
28
 
13
29
  }
14
30
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "doix-db",
3
- "version": "1.0.43",
3
+ "version": "1.0.46",
4
4
  "description": "Shared database related code for doix",
5
5
  "main": "index.js",
6
6
  "files": [
@@ -40,7 +40,7 @@
40
40
  },
41
41
  "homepage": "https://github.com/do-/node-doix-db#readme",
42
42
  "peerDependencies": {
43
- "doix": "^1.0.7"
43
+ "doix": "^1.0.10"
44
44
  },
45
45
  "devDependencies": {
46
46
  "jest": "^29.6.1"