pqb 0.26.1 → 0.26.2

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.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
- joinStatementsSet.clear();
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 (!joinStatementsSet.has(sql)) {
1006
- joinStatementsSet.add(sql);
1007
- ands.push(sql);
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
- joinStatementsSet.clear();
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 (!joinStatementsSet.has(sql)) {
1346
- joinStatementsSet.add(sql);
1347
- ctx.sql.push(sql);
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
- joinStatementsSet.clear();
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 (!joinStatementsSet.has(key)) {
2938
- joinStatementsSet.add(key);
2939
- items.push(join);
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) {