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