@dwtechs/antity-pgsql 0.11.0 → 0.11.1
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/dist/antity-pgsql.js +18 -11
- package/package.json +1 -1
package/dist/antity-pgsql.js
CHANGED
|
@@ -24,7 +24,7 @@ SOFTWARE.
|
|
|
24
24
|
https://github.com/DWTechs/Antity-pgsql.js
|
|
25
25
|
*/
|
|
26
26
|
|
|
27
|
-
import { isArray,
|
|
27
|
+
import { isArray, isString, isIn } from '@dwtechs/checkard';
|
|
28
28
|
import { deleteProps, chunk, flatten } from '@dwtechs/sparray';
|
|
29
29
|
import { log } from '@dwtechs/winstan';
|
|
30
30
|
import { Entity } from '@dwtechs/antity';
|
|
@@ -107,14 +107,6 @@ function quoteIfUppercase(word) {
|
|
|
107
107
|
function index(index, matchMode) {
|
|
108
108
|
const i = index.map((i) => `$${i}`);
|
|
109
109
|
switch (matchMode) {
|
|
110
|
-
case "startsWith":
|
|
111
|
-
return `${i}%`;
|
|
112
|
-
case "endsWith":
|
|
113
|
-
return `%${i}`;
|
|
114
|
-
case "contains":
|
|
115
|
-
return `%${i}%`;
|
|
116
|
-
case "notContains":
|
|
117
|
-
return `%${i}%`;
|
|
118
110
|
case "in":
|
|
119
111
|
return `(${i})`;
|
|
120
112
|
default:
|
|
@@ -159,6 +151,21 @@ function comparator(matchMode) {
|
|
|
159
151
|
}
|
|
160
152
|
}
|
|
161
153
|
|
|
154
|
+
function formatValue(value, matchMode) {
|
|
155
|
+
if (!isString(value))
|
|
156
|
+
return value;
|
|
157
|
+
switch (matchMode) {
|
|
158
|
+
case "startsWith":
|
|
159
|
+
return `${value}%`;
|
|
160
|
+
case "endsWith":
|
|
161
|
+
return `%${value}`;
|
|
162
|
+
case "contains":
|
|
163
|
+
case "notContains":
|
|
164
|
+
return `%${value}%`;
|
|
165
|
+
default:
|
|
166
|
+
return value;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
162
169
|
function add(filters) {
|
|
163
170
|
var _a, _b;
|
|
164
171
|
const conditions = [];
|
|
@@ -176,9 +183,9 @@ function add(filters) {
|
|
|
176
183
|
if (cond) {
|
|
177
184
|
groupConditions.push(cond);
|
|
178
185
|
if (isArray(value))
|
|
179
|
-
args.push(...value);
|
|
186
|
+
args.push(...value.map((v) => formatValue(v, matchMode)));
|
|
180
187
|
else
|
|
181
|
-
args.push(value);
|
|
188
|
+
args.push(formatValue(value, matchMode));
|
|
182
189
|
}
|
|
183
190
|
}
|
|
184
191
|
if (groupConditions.length > 0) {
|