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.mjs
CHANGED
|
@@ -654,7 +654,6 @@ const columnCode = (type, t, code, data = type.data, skip) => {
|
|
|
654
654
|
return code.length === 1 && typeof code[0] === "string" ? code[0] : code;
|
|
655
655
|
};
|
|
656
656
|
|
|
657
|
-
const joinStatementsSet = /* @__PURE__ */ new Set();
|
|
658
657
|
function simpleColumnToSQL(ctx, key, column, quotedAs) {
|
|
659
658
|
if (!column)
|
|
660
659
|
return `"${key}"`;
|
|
@@ -990,7 +989,7 @@ const processWhere = (ands, ctx, table, query, data, quotedAs) => {
|
|
|
990
989
|
});
|
|
991
990
|
} else if (key === "EXISTS") {
|
|
992
991
|
const joinItems = Array.isArray(value[0]) ? value : [value];
|
|
993
|
-
|
|
992
|
+
const joinSet = joinItems.length > 1 ? /* @__PURE__ */ new Set() : null;
|
|
994
993
|
for (const args of joinItems) {
|
|
995
994
|
const { target, conditions } = processJoinItem(
|
|
996
995
|
ctx,
|
|
@@ -1000,10 +999,12 @@ const processWhere = (ands, ctx, table, query, data, quotedAs) => {
|
|
|
1000
999
|
quotedAs
|
|
1001
1000
|
);
|
|
1002
1001
|
const sql = `EXISTS (SELECT 1 FROM ${target} WHERE ${conditions})`;
|
|
1003
|
-
if (
|
|
1004
|
-
|
|
1005
|
-
|
|
1002
|
+
if (joinSet) {
|
|
1003
|
+
if (joinSet.has(sql))
|
|
1004
|
+
continue;
|
|
1005
|
+
joinSet.add(sql);
|
|
1006
1006
|
}
|
|
1007
|
+
ands.push(sql);
|
|
1007
1008
|
}
|
|
1008
1009
|
} else if (key === "SEARCH") {
|
|
1009
1010
|
const search = value;
|
|
@@ -1320,7 +1321,7 @@ const getObjectOrRawConditions = (ctx, query, data, quotedAs, joinAs, joinShape)
|
|
|
1320
1321
|
};
|
|
1321
1322
|
const pushJoinSql = (ctx, table, query, quotedAs) => {
|
|
1322
1323
|
var _a;
|
|
1323
|
-
|
|
1324
|
+
const joinSet = query.join.length > 1 ? /* @__PURE__ */ new Set() : null;
|
|
1324
1325
|
for (const item of query.join) {
|
|
1325
1326
|
let sql;
|
|
1326
1327
|
if (Array.isArray(item)) {
|
|
@@ -1340,10 +1341,12 @@ const pushJoinSql = (ctx, table, query, quotedAs) => {
|
|
|
1340
1341
|
);
|
|
1341
1342
|
sql = conditions ? `${item.type} ${target} ON ${conditions}` : `${item.type} ${target} ON true`;
|
|
1342
1343
|
}
|
|
1343
|
-
if (
|
|
1344
|
-
|
|
1345
|
-
|
|
1344
|
+
if (joinSet) {
|
|
1345
|
+
if (joinSet.has(sql))
|
|
1346
|
+
continue;
|
|
1347
|
+
joinSet.add(sql);
|
|
1346
1348
|
}
|
|
1349
|
+
ctx.sql.push(sql);
|
|
1347
1350
|
}
|
|
1348
1351
|
};
|
|
1349
1352
|
const skipQueryKeysForSubQuery = {
|
|
@@ -2927,15 +2930,17 @@ const pushDeleteSql = (ctx, table, query, quotedAs) => {
|
|
|
2927
2930
|
let conditions;
|
|
2928
2931
|
if ((_a = query.join) == null ? void 0 : _a.length) {
|
|
2929
2932
|
const items = [];
|
|
2930
|
-
|
|
2933
|
+
const joinSet = query.join.length > 1 ? /* @__PURE__ */ new Set() : null;
|
|
2931
2934
|
for (const item of query.join) {
|
|
2932
2935
|
if (!Array.isArray(item)) {
|
|
2933
2936
|
const join = processJoinItem(ctx, table, query, item, quotedAs);
|
|
2934
2937
|
const key = `${join.target}${join.conditions}`;
|
|
2935
|
-
if (
|
|
2936
|
-
|
|
2937
|
-
|
|
2938
|
+
if (joinSet) {
|
|
2939
|
+
if (joinSet.has(key))
|
|
2940
|
+
continue;
|
|
2941
|
+
joinSet.add(key);
|
|
2938
2942
|
}
|
|
2943
|
+
items.push(join);
|
|
2939
2944
|
}
|
|
2940
2945
|
}
|
|
2941
2946
|
if (items.length) {
|