@dwtechs/antity-pgsql 0.17.6 → 0.17.7
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 +9 -7
- 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, isString } from '@dwtechs/checkard';
|
|
27
|
+
import { isArray, isInteger, isString } 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';
|
|
@@ -104,7 +104,7 @@ function quoteIfUppercase(word) {
|
|
|
104
104
|
return word;
|
|
105
105
|
}
|
|
106
106
|
|
|
107
|
-
function index(index, matchMode) {
|
|
107
|
+
function index(index, matchMode, value) {
|
|
108
108
|
const i = index.map((i) => `$${i}`);
|
|
109
109
|
switch (matchMode) {
|
|
110
110
|
case "in":
|
|
@@ -112,8 +112,10 @@ function index(index, matchMode) {
|
|
|
112
112
|
case "IN":
|
|
113
113
|
case "NOT IN":
|
|
114
114
|
return `(${i})`;
|
|
115
|
-
case "&&":
|
|
116
|
-
|
|
115
|
+
case "&&": {
|
|
116
|
+
const cast = isArray(value, ">", 0) && isInteger(value[0]) ? '::integer[]' : '';
|
|
117
|
+
return `ARRAY[${i}]${cast}`;
|
|
118
|
+
}
|
|
117
119
|
default:
|
|
118
120
|
return `${i}`;
|
|
119
121
|
}
|
|
@@ -201,7 +203,7 @@ function add(filters) {
|
|
|
201
203
|
if (shouldSkipValue(value, matchMode))
|
|
202
204
|
continue;
|
|
203
205
|
const indexes = isArray(value) ? value.map(() => i++) : [i++];
|
|
204
|
-
const cond = addOne(k, indexes, matchMode);
|
|
206
|
+
const cond = addOne(k, indexes, matchMode, value);
|
|
205
207
|
if (cond) {
|
|
206
208
|
groupConditions.push(cond);
|
|
207
209
|
if (isArray(value))
|
|
@@ -221,10 +223,10 @@ function add(filters) {
|
|
|
221
223
|
}
|
|
222
224
|
return { conditions, args };
|
|
223
225
|
}
|
|
224
|
-
function addOne(key, indexes, matchMode) {
|
|
226
|
+
function addOne(key, indexes, matchMode, value) {
|
|
225
227
|
const sqlKey = `${quoteIfUppercase(key)}`;
|
|
226
228
|
const comparator$1 = comparator(matchMode);
|
|
227
|
-
const index$1 = index(indexes, matchMode);
|
|
229
|
+
const index$1 = index(indexes, matchMode, value);
|
|
228
230
|
return comparator$1 ? `${sqlKey} ${comparator$1} ${index$1}` : "";
|
|
229
231
|
}
|
|
230
232
|
|