pqb 0.26.1 → 0.26.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 +2 -0
- package/dist/index.js +18 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +18 -13
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1338,11 +1338,13 @@ interface JBase {
|
|
|
1338
1338
|
result: QueryColumns;
|
|
1339
1339
|
shape: QueryColumns;
|
|
1340
1340
|
meta: QueryMetaBase;
|
|
1341
|
+
table?: string;
|
|
1341
1342
|
}
|
|
1342
1343
|
declare class OnQueryBuilder<S extends PickQueryMetaShape = QueryBase, J extends JBase = JBase> extends WhereQueryBase {
|
|
1343
1344
|
selectable: J['meta']['selectable'] & Omit<S['meta']['selectable'], keyof S['shape']>;
|
|
1344
1345
|
relations: J['relations'];
|
|
1345
1346
|
result: J['result'];
|
|
1347
|
+
table: J['table'];
|
|
1346
1348
|
shape: J['shape'];
|
|
1347
1349
|
withData: {};
|
|
1348
1350
|
constructor(q: QueryBase, { shape, joinedShapes }: PickQueryDataShapeAndJoinedShapes, joinTo: QueryDataJoinTo);
|
package/dist/index.js
CHANGED
|
@@ -656,7 +656,6 @@ const columnCode = (type, t, code, data = type.data, skip) => {
|
|
|
656
656
|
return code.length === 1 && typeof code[0] === "string" ? code[0] : code;
|
|
657
657
|
};
|
|
658
658
|
|
|
659
|
-
const joinStatementsSet = /* @__PURE__ */ new Set();
|
|
660
659
|
function simpleColumnToSQL(ctx, key, column, quotedAs) {
|
|
661
660
|
if (!column)
|
|
662
661
|
return `"${key}"`;
|
|
@@ -992,7 +991,7 @@ const processWhere = (ands, ctx, table, query, data, quotedAs) => {
|
|
|
992
991
|
});
|
|
993
992
|
} else if (key === "EXISTS") {
|
|
994
993
|
const joinItems = Array.isArray(value[0]) ? value : [value];
|
|
995
|
-
|
|
994
|
+
const joinSet = joinItems.length > 1 ? /* @__PURE__ */ new Set() : null;
|
|
996
995
|
for (const args of joinItems) {
|
|
997
996
|
const { target, conditions } = processJoinItem(
|
|
998
997
|
ctx,
|
|
@@ -1002,10 +1001,12 @@ const processWhere = (ands, ctx, table, query, data, quotedAs) => {
|
|
|
1002
1001
|
quotedAs
|
|
1003
1002
|
);
|
|
1004
1003
|
const sql = `EXISTS (SELECT 1 FROM ${target} WHERE ${conditions})`;
|
|
1005
|
-
if (
|
|
1006
|
-
|
|
1007
|
-
|
|
1004
|
+
if (joinSet) {
|
|
1005
|
+
if (joinSet.has(sql))
|
|
1006
|
+
continue;
|
|
1007
|
+
joinSet.add(sql);
|
|
1008
1008
|
}
|
|
1009
|
+
ands.push(sql);
|
|
1009
1010
|
}
|
|
1010
1011
|
} else if (key === "SEARCH") {
|
|
1011
1012
|
const search = value;
|
|
@@ -1322,7 +1323,7 @@ const getObjectOrRawConditions = (ctx, query, data, quotedAs, joinAs, joinShape)
|
|
|
1322
1323
|
};
|
|
1323
1324
|
const pushJoinSql = (ctx, table, query, quotedAs) => {
|
|
1324
1325
|
var _a;
|
|
1325
|
-
|
|
1326
|
+
const joinSet = query.join.length > 1 ? /* @__PURE__ */ new Set() : null;
|
|
1326
1327
|
for (const item of query.join) {
|
|
1327
1328
|
let sql;
|
|
1328
1329
|
if (Array.isArray(item)) {
|
|
@@ -1342,10 +1343,12 @@ const pushJoinSql = (ctx, table, query, quotedAs) => {
|
|
|
1342
1343
|
);
|
|
1343
1344
|
sql = conditions ? `${item.type} ${target} ON ${conditions}` : `${item.type} ${target} ON true`;
|
|
1344
1345
|
}
|
|
1345
|
-
if (
|
|
1346
|
-
|
|
1347
|
-
|
|
1346
|
+
if (joinSet) {
|
|
1347
|
+
if (joinSet.has(sql))
|
|
1348
|
+
continue;
|
|
1349
|
+
joinSet.add(sql);
|
|
1348
1350
|
}
|
|
1351
|
+
ctx.sql.push(sql);
|
|
1349
1352
|
}
|
|
1350
1353
|
};
|
|
1351
1354
|
const skipQueryKeysForSubQuery = {
|
|
@@ -2929,15 +2932,17 @@ const pushDeleteSql = (ctx, table, query, quotedAs) => {
|
|
|
2929
2932
|
let conditions;
|
|
2930
2933
|
if ((_a = query.join) == null ? void 0 : _a.length) {
|
|
2931
2934
|
const items = [];
|
|
2932
|
-
|
|
2935
|
+
const joinSet = query.join.length > 1 ? /* @__PURE__ */ new Set() : null;
|
|
2933
2936
|
for (const item of query.join) {
|
|
2934
2937
|
if (!Array.isArray(item)) {
|
|
2935
2938
|
const join = processJoinItem(ctx, table, query, item, quotedAs);
|
|
2936
2939
|
const key = `${join.target}${join.conditions}`;
|
|
2937
|
-
if (
|
|
2938
|
-
|
|
2939
|
-
|
|
2940
|
+
if (joinSet) {
|
|
2941
|
+
if (joinSet.has(key))
|
|
2942
|
+
continue;
|
|
2943
|
+
joinSet.add(key);
|
|
2940
2944
|
}
|
|
2945
|
+
items.push(join);
|
|
2941
2946
|
}
|
|
2942
2947
|
}
|
|
2943
2948
|
if (items.length) {
|