@prisma/orm-family-sql 8.0.0-rc.11-dev.27 → 8.0.0-rc.11-dev.28

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.
@@ -3690,15 +3690,14 @@ function normalizeWhereArg(arg, options) {
3690
3690
  function isToWhereExpr(arg) {
3691
3691
  return typeof arg === "object" && arg !== null && "toWhereExpr" in arg && !isWhereExpr(arg);
3692
3692
  }
3693
- function applyCreateDefaults(ctx, namespaceId, tableName, rows) {
3694
- const defaultValueCache = rows.length > 1 ? /* @__PURE__ */ new Map() : void 0;
3693
+ function applyCreateDefaults(ctx, namespaceId, tableName, rows, defaultValueCache = /* @__PURE__ */ new Map()) {
3695
3694
  for (const row of rows) {
3696
3695
  const applied = ctx.context.applyMutationDefaults({
3697
3696
  op: "create",
3698
3697
  table: tableName,
3699
3698
  namespace: namespaceId,
3700
3699
  values: row,
3701
- ...defaultValueCache ? { defaultValueCache } : {}
3700
+ defaultValueCache
3702
3701
  });
3703
3702
  for (const def of applied) row[def.column] = def.value;
3704
3703
  }
@@ -4339,6 +4338,7 @@ var CollectionImpl = class CollectionImpl {
4339
4338
  ...variantFieldToColumn
4340
4339
  };
4341
4340
  const generator = async function* () {
4341
+ const defaultValueCache = /* @__PURE__ */ new Map();
4342
4342
  for (const row of data) {
4343
4343
  const allMapped = {};
4344
4344
  for (const [fieldName, value] of Object.entries(row)) {
@@ -4354,7 +4354,7 @@ var CollectionImpl = class CollectionImpl {
4354
4354
  if (variantFieldColumns.has(col)) variantRow[col] = val;
4355
4355
  }
4356
4356
  yield blindCast(await withMutationScope(runtime, async (scope) => {
4357
- applyCreateDefaults(collectionCtx, namespaceId, tableName, [baseRow]);
4357
+ applyCreateDefaults(collectionCtx, namespaceId, tableName, [baseRow], defaultValueCache);
4358
4358
  const baseCreated = (await queryPlanRows(scope, compileInsertReturning(contract, namespaceId, tableName, [baseRow], void 0)).toArray())[0];
4359
4359
  if (!baseCreated) throw ormError("ORM.MUTATION_ROW_MISSING", `MTI base INSERT for model "${modelName}" did not return a row`, { meta: {
4360
4360
  operation: "create",
@@ -4364,7 +4364,7 @@ var CollectionImpl = class CollectionImpl {
4364
4364
  } });
4365
4365
  const pkValue = baseCreated[pkColumn];
4366
4366
  variantRow[pkColumn] = pkValue;
4367
- applyCreateDefaults(collectionCtx, namespaceId, variant.table, [variantRow]);
4367
+ applyCreateDefaults(collectionCtx, namespaceId, variant.table, [variantRow], defaultValueCache);
4368
4368
  const variantCreated = (await queryPlanRows(scope, compileInsertReturning(contract, namespaceId, variant.table, [variantRow], void 0)).toArray())[0];
4369
4369
  if (!variantCreated) throw ormError("ORM.MUTATION_ROW_MISSING", `MTI variant INSERT for model "${modelName}" into "${variant.table}" did not return a row`, { meta: {
4370
4370
  operation: "create",