pqb 0.73.4 → 0.73.5
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 +1 -1
- package/dist/index.js +19 -18
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +19 -18
- package/dist/index.mjs.map +1 -1
- package/dist/internal.d.ts +1 -1
- package/dist/internal.js +11 -10
- package/dist/internal.js.map +1 -1
- package/dist/internal.mjs +11 -10
- package/dist/internal.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -339,7 +339,7 @@ interface AdapterConfigBase {
|
|
|
339
339
|
* databaseURL: process.env.DATABASE_URL,
|
|
340
340
|
* connectRetry: {
|
|
341
341
|
* attempts: 5,
|
|
342
|
-
*
|
|
342
|
+
* strategy(currentAttempt: number, maxAttempts: number) {
|
|
343
343
|
* // linear: wait 100ms after 1st attempt, then 200m after 2nd, and so on.
|
|
344
344
|
* return setTimeout(currentAttempt * 100);
|
|
345
345
|
* },
|
package/dist/index.js
CHANGED
|
@@ -1740,6 +1740,14 @@ const columnCode = (type, ctx, key, code) => {
|
|
|
1740
1740
|
if (data.modifyQuery && !ctx.migration) addCode(code, `.modifyQuery(${data.modifyQuery.toString()})`);
|
|
1741
1741
|
return code.length === 1 && typeof code[0] === "string" ? code[0] : code;
|
|
1742
1742
|
};
|
|
1743
|
+
const queryTypeWithLimitOne = {
|
|
1744
|
+
one: true,
|
|
1745
|
+
oneOrThrow: true,
|
|
1746
|
+
value: true,
|
|
1747
|
+
valueOrThrow: true
|
|
1748
|
+
};
|
|
1749
|
+
const isQueryReturnsAll = (q) => !q.q.returnType || q.q.returnType === "all";
|
|
1750
|
+
const isQuery = (q) => !!q && typeof q === "object" && "__isQuery" in q && q.__isQuery === true;
|
|
1743
1751
|
/**
|
|
1744
1752
|
* generic utility to add a parser to the query object
|
|
1745
1753
|
* @param query - the query object, it will be mutated
|
|
@@ -2362,7 +2370,7 @@ const quoteValue = (arg, ctx, quotedAs, IN) => {
|
|
|
2362
2370
|
if (arg && typeof arg === "object") {
|
|
2363
2371
|
if (IN && isIterable(arg)) return `(${(Array.isArray(arg) ? arg : [...arg]).map((value) => addValue(ctx.values, value)).join(", ")})`;
|
|
2364
2372
|
if (isExpression(arg)) return arg.toSQL(ctx, quotedAs);
|
|
2365
|
-
if (
|
|
2373
|
+
if (isQuery(arg)) return `(${moveMutativeQueryToCte$1(ctx, arg)})`;
|
|
2366
2374
|
if (!(arg instanceof Date) && !Array.isArray(arg)) arg = JSON.stringify(arg);
|
|
2367
2375
|
}
|
|
2368
2376
|
return addValue(ctx.values, arg);
|
|
@@ -2371,7 +2379,7 @@ const quoteLikeValue = (arg, ctx, quotedAs, jsonArray) => {
|
|
|
2371
2379
|
if (arg && typeof arg === "object") {
|
|
2372
2380
|
if (!jsonArray && Array.isArray(arg)) return `(${arg.map((value) => addValue(ctx.values, value)).join(", ")})`;
|
|
2373
2381
|
if (isExpression(arg)) return arg.toSQL(ctx, quotedAs);
|
|
2374
|
-
if (
|
|
2382
|
+
if (isQuery(arg)) return `replace(replace((${moveMutativeQueryToCte$1(ctx, arg)}), '%', '\\\\%'), '_', '\\\\_')`;
|
|
2375
2383
|
}
|
|
2376
2384
|
return addValue(ctx.values, arg.replace(/[%_]/g, "\\$&"));
|
|
2377
2385
|
};
|
|
@@ -2411,20 +2419,21 @@ const ordinalText = {
|
|
|
2411
2419
|
};
|
|
2412
2420
|
const encodeJsonPath = (ctx, path) => addValue(ctx.values, `{${Array.isArray(path) ? path.join(", ") : path}}`);
|
|
2413
2421
|
const jsonPathQueryOp = (key, [path, options], ctx) => `jsonb_path_query_first(${key}, ${addValue(ctx.values, path)}${options?.vars ? `, ${addValue(ctx.values, JSON.stringify(options.vars))}${options.silent ? ", true" : ""}` : options?.silent ? ", NULL, true" : ""})`;
|
|
2414
|
-
const
|
|
2422
|
+
const encodeJsonIfNeeded = (ctx, value) => ctx.q.adapter.driverAdapter.schemaConfig?.jsonEncodedByDriver === false ? JSON.stringify(value) : value;
|
|
2423
|
+
const quoteJsonOperand = (arg, ctx, quotedAs) => isExpression(arg) || isQuery(arg) ? quoteValue(arg, ctx, quotedAs) : addValue(ctx.values, encodeJsonIfNeeded(ctx, arg));
|
|
2415
2424
|
const quoteJsonValue = (arg, ctx, quotedAs, IN) => {
|
|
2416
2425
|
if (arg && typeof arg === "object") {
|
|
2417
|
-
if (IN && Array.isArray(arg)) return `(${arg.map((value) =>
|
|
2418
|
-
if (Array.isArray(arg)) return
|
|
2426
|
+
if (IN && Array.isArray(arg)) return `(${arg.map((value) => addValue(ctx.values, encodeJsonIfNeeded(ctx, value))).join(", ")})`;
|
|
2427
|
+
if (Array.isArray(arg)) return addValue(ctx.values, encodeJsonIfNeeded(ctx, arg));
|
|
2419
2428
|
if (isExpression(arg)) return "to_jsonb(" + arg.toSQL(ctx, quotedAs) + ")";
|
|
2420
|
-
if (
|
|
2429
|
+
if (isQuery(arg)) return `to_jsonb((${moveMutativeQueryToCte$1(ctx, arg)}))`;
|
|
2421
2430
|
}
|
|
2422
|
-
return
|
|
2431
|
+
return addValue(ctx.values, encodeJsonIfNeeded(ctx, arg));
|
|
2423
2432
|
};
|
|
2424
2433
|
const serializeJsonValue = (arg, ctx, quotedAs) => {
|
|
2425
2434
|
if (arg && typeof arg === "object") {
|
|
2426
2435
|
if (isExpression(arg)) return "to_jsonb(" + arg.toSQL(ctx, quotedAs) + ")";
|
|
2427
|
-
if (
|
|
2436
|
+
if (isQuery(arg)) return `to_jsonb((${moveMutativeQueryToCte$1(ctx, arg)}))`;
|
|
2428
2437
|
}
|
|
2429
2438
|
return addValue(ctx.values, JSON.stringify(arg));
|
|
2430
2439
|
};
|
|
@@ -2461,8 +2470,8 @@ const Operators = {
|
|
|
2461
2470
|
}
|
|
2462
2471
|
return this;
|
|
2463
2472
|
}, { _op: jsonPathQueryOp }),
|
|
2464
|
-
jsonSupersetOf: make((key, value, ctx, quotedAs) => `${key} @> ${
|
|
2465
|
-
jsonSubsetOf: make((key, value, ctx, quotedAs) => `${key} <@ ${
|
|
2473
|
+
jsonSupersetOf: make((key, value, ctx, quotedAs) => `${key} @> ${quoteJsonOperand(value, ctx, quotedAs)}`),
|
|
2474
|
+
jsonSubsetOf: make((key, value, ctx, quotedAs) => `${key} <@ ${quoteJsonOperand(value, ctx, quotedAs)}`),
|
|
2466
2475
|
jsonSet: makeVarArg((key, [path, value], ctx, quotedAs) => `jsonb_set(${key}, ${encodeJsonPath(ctx, path)}, ${serializeJsonValue(value, ctx, quotedAs)})`),
|
|
2467
2476
|
jsonReplace: makeVarArg((key, [path, value], ctx, quotedAs) => `jsonb_set(${key}, ${encodeJsonPath(ctx, path)}, ${serializeJsonValue(value, ctx, quotedAs)}, false)`),
|
|
2468
2477
|
jsonInsert: makeVarArg((key, [path, value, options], ctx, quotedAs) => `jsonb_insert(${key}, ${encodeJsonPath(ctx, path)}, ${serializeJsonValue(value, ctx, quotedAs)}${options?.after ? ", true" : ""})`),
|
|
@@ -5668,14 +5677,6 @@ var QueryWrap = class {
|
|
|
5668
5677
|
return queryWrap(this, _clone(query), as);
|
|
5669
5678
|
}
|
|
5670
5679
|
};
|
|
5671
|
-
const queryTypeWithLimitOne = {
|
|
5672
|
-
one: true,
|
|
5673
|
-
oneOrThrow: true,
|
|
5674
|
-
value: true,
|
|
5675
|
-
valueOrThrow: true
|
|
5676
|
-
};
|
|
5677
|
-
const isQueryReturnsAll = (q) => !q.q.returnType || q.q.returnType === "all";
|
|
5678
|
-
const isQuery = (q) => !!q && typeof q === "object" && "__isQuery" in q && q.__isQuery === true;
|
|
5679
5680
|
const skipQueryKeysForSubQuery = {
|
|
5680
5681
|
adapter: true,
|
|
5681
5682
|
schema: true,
|