pqb 0.52.2 → 0.52.3
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 +41 -29
- package/dist/index.js +19 -21
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +19 -21
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -493,7 +493,7 @@ const columnsShapeToCode = (ctx, shape) => {
|
|
|
493
493
|
if (name === key) column.data.name = void 0;
|
|
494
494
|
code.push(
|
|
495
495
|
...combineCodeElements([
|
|
496
|
-
`${quoteObjectKey(key)}: `,
|
|
496
|
+
`${quoteObjectKey(key, ctx.snakeCase)}: `,
|
|
497
497
|
...toArray(shape[key].toCode(ctx, key)),
|
|
498
498
|
","
|
|
499
499
|
])
|
|
@@ -2144,7 +2144,7 @@ class TsVectorColumn extends ColumnType {
|
|
|
2144
2144
|
const pairs = [];
|
|
2145
2145
|
for (const key in target) {
|
|
2146
2146
|
pairs.push(
|
|
2147
|
-
`${quoteObjectKey(key)}: '${target[key]}'`
|
|
2147
|
+
`${quoteObjectKey(key, false)}: '${target[key]}'`
|
|
2148
2148
|
);
|
|
2149
2149
|
}
|
|
2150
2150
|
code += `{ ${pairs.join(", ")} }`;
|
|
@@ -2656,8 +2656,8 @@ const _join = (query, require, type, first, args) => {
|
|
|
2656
2656
|
joinKey = first;
|
|
2657
2657
|
const relation = query.relations[joinKey];
|
|
2658
2658
|
if (relation) {
|
|
2659
|
-
shape = getShapeFromSelect(relation.
|
|
2660
|
-
const r = relation.
|
|
2659
|
+
shape = getShapeFromSelect(relation.query);
|
|
2660
|
+
const r = relation.query;
|
|
2661
2661
|
parsers = r.q.parsers;
|
|
2662
2662
|
batchParsers = r.q.batchParsers;
|
|
2663
2663
|
computeds = r.q.computeds;
|
|
@@ -2746,7 +2746,7 @@ const _joinLateralProcessArg = (q, arg, cb) => {
|
|
|
2746
2746
|
if (typeof arg === "string") {
|
|
2747
2747
|
relation = q.relations[arg];
|
|
2748
2748
|
if (relation) {
|
|
2749
|
-
arg = _clone(relation.
|
|
2749
|
+
arg = _clone(relation.query);
|
|
2750
2750
|
} else {
|
|
2751
2751
|
const w = q.q.withShapes?.[arg];
|
|
2752
2752
|
if (w) {
|
|
@@ -2768,7 +2768,7 @@ const _joinLateralProcessArg = (q, arg, cb) => {
|
|
|
2768
2768
|
cb
|
|
2769
2769
|
);
|
|
2770
2770
|
if (relation) {
|
|
2771
|
-
result = relation.
|
|
2771
|
+
result = relation.joinQuery(
|
|
2772
2772
|
result,
|
|
2773
2773
|
q
|
|
2774
2774
|
);
|
|
@@ -3573,7 +3573,7 @@ const then = async (q, adapter, trx, beforeHooks, afterHooks, afterCommitHooks,
|
|
|
3573
3573
|
if (query.transform) {
|
|
3574
3574
|
result = applyTransforms(query, returnType, query.transform, result);
|
|
3575
3575
|
}
|
|
3576
|
-
return resolve
|
|
3576
|
+
return resolve ? resolve(result) : result;
|
|
3577
3577
|
} catch (err) {
|
|
3578
3578
|
let error;
|
|
3579
3579
|
if (err instanceof pg.DatabaseError) {
|
|
@@ -6276,7 +6276,7 @@ const getIsJoinSubQuery = (query) => {
|
|
|
6276
6276
|
const processJoinArgs = (joinTo, first, args, joinSubQuery, whereExists) => {
|
|
6277
6277
|
if (typeof first === "string") {
|
|
6278
6278
|
if (first in joinTo.relations) {
|
|
6279
|
-
const { query: toQuery, joinQuery } = joinTo.relations[first]
|
|
6279
|
+
const { query: toQuery, joinQuery } = joinTo.relations[first];
|
|
6280
6280
|
const j = joinQuery(toQuery, joinTo);
|
|
6281
6281
|
if (typeof args[0] === "function") {
|
|
6282
6282
|
const r = args[0](
|
|
@@ -6376,7 +6376,9 @@ const processJoinArgs = (joinTo, first, args, joinSubQuery, whereExists) => {
|
|
|
6376
6376
|
};
|
|
6377
6377
|
const preprocessJoinArg = (q, arg) => {
|
|
6378
6378
|
if (typeof arg !== "function") return arg;
|
|
6379
|
-
arg = arg(
|
|
6379
|
+
arg = arg(
|
|
6380
|
+
q.relationQueries
|
|
6381
|
+
);
|
|
6380
6382
|
arg.joinQueryAfterCallback = arg.joinQuery;
|
|
6381
6383
|
return arg;
|
|
6382
6384
|
};
|
|
@@ -7196,9 +7198,9 @@ const _chain = (fromQuery, toQuery, rel) => {
|
|
|
7196
7198
|
q.returnType = q.returnsOne = q.limit = void 0;
|
|
7197
7199
|
}
|
|
7198
7200
|
if (self.q.relChain) {
|
|
7199
|
-
q.relChain = [...self.q.relChain, self];
|
|
7201
|
+
q.relChain = [...self.q.relChain, { query: self, rel }];
|
|
7200
7202
|
} else {
|
|
7201
|
-
q.relChain = [self];
|
|
7203
|
+
q.relChain = [{ query: self, rel }];
|
|
7202
7204
|
}
|
|
7203
7205
|
const aliases = self.q.as ? { ...self.q.aliases } : { ...self.q.aliases, [self.table]: self.table };
|
|
7204
7206
|
const relAliases = q.aliases;
|
|
@@ -7235,7 +7237,7 @@ const resolveSubQueryCallbackV2 = (q, cb) => {
|
|
|
7235
7237
|
for (const key in relations) {
|
|
7236
7238
|
Object.defineProperty(base, key, {
|
|
7237
7239
|
get() {
|
|
7238
|
-
const rel = relations[key]
|
|
7240
|
+
const rel = relations[key];
|
|
7239
7241
|
const relQuery = _clone(rel.query);
|
|
7240
7242
|
relQuery.q.withShapes = this.q.withShapes;
|
|
7241
7243
|
return _chain(this, relQuery, rel);
|
|
@@ -7255,11 +7257,8 @@ const resolveSubQueryCallbackV2 = (q, cb) => {
|
|
|
7255
7257
|
return cb(arg);
|
|
7256
7258
|
};
|
|
7257
7259
|
const joinSubQuery = (q, sub) => {
|
|
7258
|
-
if (!("
|
|
7259
|
-
return sub.
|
|
7260
|
-
sub,
|
|
7261
|
-
q
|
|
7262
|
-
);
|
|
7260
|
+
if (!("joinQuery" in sub)) return sub;
|
|
7261
|
+
return sub.joinQuery(sub, q);
|
|
7263
7262
|
};
|
|
7264
7263
|
|
|
7265
7264
|
const defaultSrid = 4326;
|
|
@@ -12673,12 +12672,10 @@ class QueryMethods {
|
|
|
12673
12672
|
return condition ? fn(this) : this;
|
|
12674
12673
|
}
|
|
12675
12674
|
queryRelated(relName, params) {
|
|
12676
|
-
return this.relations[relName].
|
|
12677
|
-
params
|
|
12678
|
-
);
|
|
12675
|
+
return this.relations[relName].queryRelated(params);
|
|
12679
12676
|
}
|
|
12680
12677
|
chain(relName) {
|
|
12681
|
-
const rel = this.relations[relName]
|
|
12678
|
+
const rel = this.relations[relName];
|
|
12682
12679
|
return _chain(this, _clone(rel.query), rel);
|
|
12683
12680
|
}
|
|
12684
12681
|
}
|
|
@@ -12837,6 +12834,7 @@ class Db extends QueryMethods {
|
|
|
12837
12834
|
};
|
|
12838
12835
|
this.baseQuery = this;
|
|
12839
12836
|
this.relations = {};
|
|
12837
|
+
this.relationQueries = {};
|
|
12840
12838
|
const logger = options.logger || console;
|
|
12841
12839
|
const parsers = {};
|
|
12842
12840
|
let hasParsers = false;
|