pqb 0.43.2 → 0.43.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.js CHANGED
@@ -5765,9 +5765,10 @@ const makeInsertSql = (ctx, q, query, quotedAs) => {
5765
5765
  }
5766
5766
  pushWhereStatementSql(ctx, q, query, quotedAs);
5767
5767
  let returning;
5768
- if (inCTE?.selectNum) {
5768
+ if (inCTE) {
5769
+ const select = inCTE.returning?.select;
5769
5770
  returning = {
5770
- select: inCTE.returning?.select ? "1, " + inCTE.returning.select : "1",
5771
+ select: inCTE.selectNum || !select ? select ? "1, " + select : "1" : select,
5771
5772
  hookSelect: inCTE.returning?.hookSelect
5772
5773
  };
5773
5774
  } else {
@@ -5963,8 +5964,6 @@ const makeReturningSql = (ctx, q, data, quotedAs, hookSelectI, addHookSelectI) =
5963
5964
  let sql;
5964
5965
  if (tempSelect?.size || select?.length) {
5965
5966
  sql = selectToSql(ctx, q, data, quotedAs, tempSelect, void 0, true);
5966
- } else if (addHookSelectI) {
5967
- sql = "1";
5968
5967
  }
5969
5968
  return { select: sql, hookSelect: tempSelect };
5970
5969
  };
@@ -5988,7 +5987,7 @@ const selectToSql = (ctx, table, query, quotedAs, hookSelect = query.hookSelect,
5988
5987
  query,
5989
5988
  quotedAs
5990
5989
  );
5991
- return query.inCTE.selectNum ? select ? "0, " + select : "0" : select || "";
5990
+ return query.inCTE.selectNum || !select ? select ? "0, " + select : "0" : select;
5992
5991
  }
5993
5992
  let selected;
5994
5993
  const list = [];
@@ -6484,7 +6483,7 @@ const pushUpdateReturning = (ctx, table, query, quotedAs, keyword) => {
6484
6483
  1,
6485
6484
  inCTE && 2
6486
6485
  );
6487
- const s = inCTE?.selectNum ? select ? "0, " + select : "0" : select;
6486
+ const s = inCTE && (inCTE.selectNum || !select) ? select ? "0, " + select : "0" : select;
6488
6487
  if (s) ctx.sql.push(keyword, s);
6489
6488
  return hookSelect;
6490
6489
  };