pqb 0.37.0 → 0.38.0
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/index.d.ts +13 -2
- package/dist/index.js +26 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +26 -9
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -933,6 +933,22 @@ const quoteValue$1 = (arg, ctx, quotedAs, jsonArray) => {
|
|
|
933
933
|
}
|
|
934
934
|
return addValue(ctx.values, arg);
|
|
935
935
|
};
|
|
936
|
+
const quoteLikeValue = (arg, ctx, quotedAs, jsonArray) => {
|
|
937
|
+
if (arg && typeof arg === "object") {
|
|
938
|
+
if (!jsonArray && Array.isArray(arg)) {
|
|
939
|
+
return `(${arg.map((value) => addValue(ctx.values, value)).join(", ")})`;
|
|
940
|
+
}
|
|
941
|
+
if (isExpression(arg)) {
|
|
942
|
+
return arg.toSQL(ctx, quotedAs);
|
|
943
|
+
}
|
|
944
|
+
if ("toSQL" in arg) {
|
|
945
|
+
return `replace(replace((${getSqlText(
|
|
946
|
+
arg.toSQL({ values: ctx.values })
|
|
947
|
+
)}), '%', '\\\\%'), '_', '\\\\_')`;
|
|
948
|
+
}
|
|
949
|
+
}
|
|
950
|
+
return addValue(ctx.values, arg.replace(/[%_]/g, "\\$&"));
|
|
951
|
+
};
|
|
936
952
|
const base = {
|
|
937
953
|
equals: make(
|
|
938
954
|
(key, value, ctx, quotedAs) => value === null ? `${key} IS NULL` : `${key} = ${quoteValue$1(value, ctx, quotedAs)}`
|
|
@@ -978,22 +994,22 @@ const numeric = __spreadProps$9(__spreadValues$j({}, base), {
|
|
|
978
994
|
});
|
|
979
995
|
const text = __spreadProps$9(__spreadValues$j({}, base), {
|
|
980
996
|
contains: make(
|
|
981
|
-
(key, value, ctx, quotedAs) => `${key} ILIKE '%' || ${
|
|
997
|
+
(key, value, ctx, quotedAs) => `${key} ILIKE '%' || ${quoteLikeValue(value, ctx, quotedAs)} || '%'`
|
|
982
998
|
),
|
|
983
999
|
containsSensitive: make(
|
|
984
|
-
(key, value, ctx, quotedAs) => `${key} LIKE '%' || ${
|
|
1000
|
+
(key, value, ctx, quotedAs) => `${key} LIKE '%' || ${quoteLikeValue(value, ctx, quotedAs)} || '%'`
|
|
985
1001
|
),
|
|
986
1002
|
startsWith: make(
|
|
987
|
-
(key, value, ctx, quotedAs) => `${key} ILIKE ${
|
|
1003
|
+
(key, value, ctx, quotedAs) => `${key} ILIKE ${quoteLikeValue(value, ctx, quotedAs)} || '%'`
|
|
988
1004
|
),
|
|
989
1005
|
startsWithSensitive: make(
|
|
990
|
-
(key, value, ctx, quotedAs) => `${key} LIKE ${
|
|
1006
|
+
(key, value, ctx, quotedAs) => `${key} LIKE ${quoteLikeValue(value, ctx, quotedAs)} || '%'`
|
|
991
1007
|
),
|
|
992
1008
|
endsWith: make(
|
|
993
|
-
(key, value, ctx, quotedAs) => `${key} ILIKE '%' || ${
|
|
1009
|
+
(key, value, ctx, quotedAs) => `${key} ILIKE '%' || ${quoteLikeValue(value, ctx, quotedAs)}`
|
|
994
1010
|
),
|
|
995
1011
|
endsWithSensitive: make(
|
|
996
|
-
(key, value, ctx, quotedAs) => `${key} LIKE '%' || ${
|
|
1012
|
+
(key, value, ctx, quotedAs) => `${key} LIKE '%' || ${quoteLikeValue(value, ctx, quotedAs)}`
|
|
997
1013
|
)
|
|
998
1014
|
});
|
|
999
1015
|
const encodeJsonPath = (ctx, path) => addValue(ctx.values, `{${Array.isArray(path) ? path.join(", ") : path}}`);
|
|
@@ -1007,9 +1023,10 @@ const json = __spreadProps$9(__spreadValues$j({}, base), {
|
|
|
1007
1023
|
this.q.parsers[getValueKey] = void 0;
|
|
1008
1024
|
}
|
|
1009
1025
|
if (options == null ? void 0 : options.type) {
|
|
1010
|
-
const
|
|
1011
|
-
if (
|
|
1012
|
-
((_e = (_d = this.q).parsers) != null ? _e : _d.parsers = {})[getValueKey] =
|
|
1026
|
+
const type = options.type(this.columnTypes);
|
|
1027
|
+
if (type.parseFn)
|
|
1028
|
+
((_e = (_d = this.q).parsers) != null ? _e : _d.parsers = {})[getValueKey] = type.parseFn;
|
|
1029
|
+
return setQueryOperators(this, type.operators);
|
|
1013
1030
|
}
|
|
1014
1031
|
return this;
|
|
1015
1032
|
},
|