pqb 0.57.2 → 0.57.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
@@ -7602,14 +7602,17 @@ const makeInsertSql = (ctx, q, query, quotedAs, isSubSql) => {
7602
7602
  (column) => `"${shape[column]?.data.name || column}"`
7603
7603
  );
7604
7604
  let runtimeDefaults;
7605
+ let runtimeDefaultColumns;
7605
7606
  if (q.internal.runtimeDefaultColumns) {
7606
7607
  runtimeDefaults = [];
7608
+ runtimeDefaultColumns = [];
7607
7609
  for (const key of q.internal.runtimeDefaultColumns) {
7608
7610
  if (!columns.includes(key)) {
7609
7611
  const column = shape[key];
7610
7612
  columns.push(key);
7611
7613
  quotedColumns.push(`"${column.data.name || key}"`);
7612
7614
  runtimeDefaults.push(column.data.runtimeDefault);
7615
+ runtimeDefaultColumns.push(key);
7613
7616
  }
7614
7617
  }
7615
7618
  }
@@ -7671,7 +7674,10 @@ const makeInsertSql = (ctx, q, query, quotedAs, isSubSql) => {
7671
7674
  const name = shape[merge]?.data.name || merge;
7672
7675
  sql = `DO UPDATE SET "${name}" = excluded."${name}"`;
7673
7676
  } else if ("except" in merge) {
7674
- sql = mergeColumnsSql(columns, quotedColumns, target, merge.except);
7677
+ sql = mergeColumnsSql(columns, quotedColumns, target, [
7678
+ ...toArray(merge.except),
7679
+ ...runtimeDefaultColumns || emptyArray
7680
+ ]);
7675
7681
  } else {
7676
7682
  sql = `DO UPDATE SET ${merge.reduce((sql2, item, i) => {
7677
7683
  const name = shape[item]?.data.name || item;
@@ -7679,7 +7685,12 @@ const makeInsertSql = (ctx, q, query, quotedAs, isSubSql) => {
7679
7685
  }, "")}`;
7680
7686
  }
7681
7687
  } else {
7682
- sql = mergeColumnsSql(columns, quotedColumns, target);
7688
+ sql = mergeColumnsSql(
7689
+ columns,
7690
+ quotedColumns,
7691
+ target,
7692
+ runtimeDefaultColumns
7693
+ );
7683
7694
  }
7684
7695
  ctx.sql.push(sql);
7685
7696
  } else if (query.onConflict.set) {