doix-db 0.0.18 → 0.0.19
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/DbLang.js +18 -2
- package/lib/query/DbQuery.js +3 -1
- package/lib/query/DbQueryTableColumnComparison.js +20 -13
- package/package.json +1 -1
package/lib/DbLang.js
CHANGED
|
@@ -74,6 +74,14 @@ class DbLang {
|
|
|
74
74
|
|
|
75
75
|
switch (filter.op) {
|
|
76
76
|
|
|
77
|
+
case 'ILIKE':
|
|
78
|
+
filter.expr = 'UPPER(' + filter.expr + ') LIKE UPPER(?)'
|
|
79
|
+
return null
|
|
80
|
+
|
|
81
|
+
case 'NOT ILIKE':
|
|
82
|
+
filter.expr = 'UPPER(' + filter.expr + ') NOT LIKE UPPER(?)'
|
|
83
|
+
return null
|
|
84
|
+
|
|
77
85
|
case '=':
|
|
78
86
|
case '<':
|
|
79
87
|
case '>':
|
|
@@ -124,7 +132,7 @@ class DbLang {
|
|
|
124
132
|
|
|
125
133
|
from += ' AND '
|
|
126
134
|
|
|
127
|
-
from =
|
|
135
|
+
from = this.appendFilter (from, params, filter)
|
|
128
136
|
|
|
129
137
|
}
|
|
130
138
|
|
|
@@ -148,7 +156,7 @@ class DbLang {
|
|
|
148
156
|
|
|
149
157
|
if (where.length !== 0) where += ' AND '
|
|
150
158
|
|
|
151
|
-
where =
|
|
159
|
+
where = this.appendFilter (where, params, filter)
|
|
152
160
|
|
|
153
161
|
}
|
|
154
162
|
|
|
@@ -164,6 +172,14 @@ class DbLang {
|
|
|
164
172
|
|
|
165
173
|
}
|
|
166
174
|
|
|
175
|
+
appendFilter (sql, params, filter) {
|
|
176
|
+
|
|
177
|
+
for (const p of filter.params) params.push (p)
|
|
178
|
+
|
|
179
|
+
return sql + filter.expr
|
|
180
|
+
|
|
181
|
+
}
|
|
182
|
+
|
|
167
183
|
genCreateMockView ({qName, columns}) {
|
|
168
184
|
|
|
169
185
|
return 'CREATE VIEW ' + qName + ' AS SELECT ' + Object.values (columns)
|
package/lib/query/DbQuery.js
CHANGED
|
@@ -8,7 +8,7 @@ class DbQueryTableColumnComparison {
|
|
|
8
8
|
|
|
9
9
|
this.op = op.toUpperCase ()
|
|
10
10
|
|
|
11
|
-
this.expr = table.qName + '.' + this.column.qName
|
|
11
|
+
this.expr = table.qName + '.' + this.column.qName
|
|
12
12
|
|
|
13
13
|
this.setParams (value)
|
|
14
14
|
|
|
@@ -16,6 +16,18 @@ class DbQueryTableColumnComparison {
|
|
|
16
16
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
+
clone (table) {
|
|
20
|
+
|
|
21
|
+
const result = new DbQueryTableColumnComparison (table, this.column.name, this.op, this.params)
|
|
22
|
+
|
|
23
|
+
result.expr = this.expr
|
|
24
|
+
|
|
25
|
+
result.params = this.params
|
|
26
|
+
|
|
27
|
+
return result
|
|
28
|
+
|
|
29
|
+
}
|
|
30
|
+
|
|
19
31
|
setParams (value) {
|
|
20
32
|
|
|
21
33
|
const {op, table} = this, {lang} = table
|
|
@@ -24,6 +36,8 @@ class DbQueryTableColumnComparison {
|
|
|
24
36
|
|
|
25
37
|
this.params = []
|
|
26
38
|
|
|
39
|
+
this.expr += ' ' + op
|
|
40
|
+
|
|
27
41
|
return
|
|
28
42
|
|
|
29
43
|
}
|
|
@@ -41,9 +55,10 @@ class DbQueryTableColumnComparison {
|
|
|
41
55
|
if (this.op !== 'IN' && this.op !== 'NOT IN') {
|
|
42
56
|
|
|
43
57
|
this.params = Array.isArray (value) ? value : [value]
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
58
|
+
|
|
59
|
+
const right = lang.genComparisonRightPart (this)
|
|
60
|
+
|
|
61
|
+
if (right !== null) this.expr += ' ' + op + ' ' + right
|
|
47
62
|
|
|
48
63
|
return
|
|
49
64
|
|
|
@@ -62,20 +77,12 @@ class DbQueryTableColumnComparison {
|
|
|
62
77
|
|
|
63
78
|
this.params = value
|
|
64
79
|
|
|
65
|
-
this.expr += ' '
|
|
80
|
+
this.expr += ' ' + op + ' '
|
|
66
81
|
this.expr += lang.genComparisonRightPart (this)
|
|
67
82
|
|
|
68
83
|
}
|
|
69
84
|
|
|
70
85
|
}
|
|
71
|
-
|
|
72
|
-
appendTo (sql, params) {
|
|
73
|
-
|
|
74
|
-
for (const p of this.params) params.push (p)
|
|
75
|
-
|
|
76
|
-
return sql + this.expr
|
|
77
|
-
|
|
78
|
-
}
|
|
79
86
|
|
|
80
87
|
}
|
|
81
88
|
|