@prisma/orm-family-sql 8.0.0-rc.11-dev.36 → 8.0.0-rc.11-dev.38

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.
Files changed (90) hide show
  1. package/dist/{aggregate-descriptor-registry-YRK_hT8V.mjs → aggregate-descriptor-registry-DzThdoju.mjs} +2 -2
  2. package/dist/{aggregate-descriptor-registry-YRK_hT8V.mjs.map → aggregate-descriptor-registry-DzThdoju.mjs.map} +1 -1
  3. package/dist/{ast-D7JjbK8E.d.mts → ast-BHZ0g4iL.d.mts} +3 -3
  4. package/dist/{ast-D7JjbK8E.d.mts.map → ast-BHZ0g4iL.d.mts.map} +1 -1
  5. package/dist/{ast-CS0lZ0OC.mjs → ast-C8jX7HNs.mjs} +2 -2
  6. package/dist/{ast-CS0lZ0OC.mjs.map → ast-C8jX7HNs.mjs.map} +1 -1
  7. package/dist/builder.d.mts +2 -2
  8. package/dist/builder__runtime.d.mts +6 -6
  9. package/dist/builder__runtime.mjs +2 -2
  10. package/dist/builder__types.d.mts +2 -2
  11. package/dist/{control-CuiTzy6O.d.mts → control-C9oCqe39.d.mts} +6 -6
  12. package/dist/{control-CuiTzy6O.d.mts.map → control-C9oCqe39.d.mts.map} +1 -1
  13. package/dist/control-adapter-Bx5ZQKj-.d.mts +1 -0
  14. package/dist/{control-adapter-C99J7aEF-QiVMjPGA.d.mts → control-adapter-C99J7aEF-B2G4GA5s.d.mts} +4 -4
  15. package/dist/{control-adapter-C99J7aEF-QiVMjPGA.d.mts.map → control-adapter-C99J7aEF-B2G4GA5s.d.mts.map} +1 -1
  16. package/dist/{db-BhQdL6Za-CnAcF6Zh.d.mts → db-BhQdL6Za-Dod07quT.d.mts} +6 -6
  17. package/dist/{db-BhQdL6Za-CnAcF6Zh.d.mts.map → db-BhQdL6Za-Dod07quT.d.mts.map} +1 -1
  18. package/dist/{ddl-types-CA-aj1rO-_giNpXNM.d.mts → ddl-types-Biy7miT--CSyPnOHq.d.mts} +3 -3
  19. package/dist/{ddl-types-CA-aj1rO-_giNpXNM.d.mts.map → ddl-types-Biy7miT--CSyPnOHq.d.mts.map} +1 -1
  20. package/dist/{diff-BB4zE5J1.d.mts → diff-CwozLSiO.d.mts} +3 -3
  21. package/dist/{diff-BB4zE5J1.d.mts.map → diff-CwozLSiO.d.mts.map} +1 -1
  22. package/dist/{expression-C7JqFgwS.d.mts → expression-CTADTPZW.d.mts} +3 -3
  23. package/dist/{expression-C7JqFgwS.d.mts.map → expression-CTADTPZW.d.mts.map} +1 -1
  24. package/dist/{expression-CiiHMYqY.mjs → expression-DqrE3myO.mjs} +2 -2
  25. package/dist/{expression-CiiHMYqY.mjs.map → expression-DqrE3myO.mjs.map} +1 -1
  26. package/dist/family.d.mts +7 -7
  27. package/dist/family__control-adapter.d.mts +2 -2
  28. package/dist/family__control.d.mts +2 -2
  29. package/dist/family__diff.d.mts +2 -2
  30. package/dist/family__migration.d.mts +1 -1
  31. package/dist/family__runtime.d.mts +1 -1
  32. package/dist/{index-DfRCPDMK.d.mts → index-CA_WLNy1.d.mts} +9 -9
  33. package/dist/{index-DfRCPDMK.d.mts.map → index-CA_WLNy1.d.mts.map} +1 -1
  34. package/dist/{middleware-CAQqWuBd-D-9cpkrQ.d.mts → middleware-0yjzaoBT-BqmCD6Dt.d.mts} +3 -3
  35. package/dist/{middleware-CAQqWuBd-D-9cpkrQ.d.mts.map → middleware-0yjzaoBT-BqmCD6Dt.d.mts.map} +1 -1
  36. package/dist/middleware-Di3_d2T5.d.mts +1 -0
  37. package/dist/{migration-ClbaU5Om.d.mts → migration-CniGZoFt.d.mts} +2 -2
  38. package/dist/{migration-ClbaU5Om.d.mts.map → migration-CniGZoFt.d.mts.map} +1 -1
  39. package/dist/orm-client.d.mts +44 -15
  40. package/dist/orm-client.d.mts.map +1 -1
  41. package/dist/orm-client.mjs +97 -26
  42. package/dist/orm-client.mjs.map +1 -1
  43. package/dist/plan-BEJGOQ-l.d.mts +2 -0
  44. package/dist/{plan-oIjoMLQN-VIXmqAKW.d.mts → plan-Bs-Pdirc-BCy94--G.d.mts} +3 -3
  45. package/dist/plan-Bs-Pdirc-BCy94--G.d.mts.map +1 -0
  46. package/dist/{prepared-statement-DZtymlzd-D_INawdF.d.mts → prepared-statement-DZtymlzd-DFIuG_WK.d.mts} +13 -13
  47. package/dist/{prepared-statement-DZtymlzd-D_INawdF.d.mts.map → prepared-statement-DZtymlzd-DFIuG_WK.d.mts.map} +1 -1
  48. package/dist/{query-lane-context-cqWxvUWZ-Cl8U5ljU.d.mts → query-lane-context-QIUURgPP-CvQ9jQRm.d.mts} +3 -3
  49. package/dist/{query-lane-context-cqWxvUWZ-Cl8U5ljU.d.mts.map → query-lane-context-QIUURgPP-CvQ9jQRm.d.mts.map} +1 -1
  50. package/dist/query-lane-context-yy5kDAlG.d.mts +1 -0
  51. package/dist/relational-core.d.mts +11 -11
  52. package/dist/relational-core.mjs +3 -3
  53. package/dist/relational-core__aggregate-descriptor-registry.d.mts +1 -1
  54. package/dist/relational-core__aggregate-descriptor-registry.mjs +1 -1
  55. package/dist/relational-core__ast.d.mts +3 -3
  56. package/dist/relational-core__ast.mjs +2 -2
  57. package/dist/relational-core__codec-descriptor-registry.d.mts +2 -2
  58. package/dist/relational-core__contract-free.d.mts +2 -2
  59. package/dist/relational-core__contract-free.mjs +1 -1
  60. package/dist/relational-core__contract-free.mjs.map +1 -1
  61. package/dist/relational-core__expression.d.mts +1 -1
  62. package/dist/relational-core__expression.mjs +1 -1
  63. package/dist/relational-core__middleware.d.mts +2 -2
  64. package/dist/relational-core__plan.d.mts +3 -3
  65. package/dist/relational-core__query-lane-context.d.mts +2 -2
  66. package/dist/relational-core__types.d.mts +2 -2
  67. package/dist/{runtime-C-gasTpn.d.mts → runtime-gCSNgykk.d.mts} +3 -3
  68. package/dist/{runtime-C-gasTpn.d.mts.map → runtime-gCSNgykk.d.mts.map} +1 -1
  69. package/dist/runtime.d.mts +4 -4
  70. package/dist/runtime.mjs +2 -2
  71. package/dist/runtime__internal__prepared-query.d.mts +1 -1
  72. package/dist/{sql-execution-plan-2C68q5Jo-BCQaqOt4.d.mts → sql-execution-plan-S3HvDKIP-8KF1nBHu.d.mts} +3 -3
  73. package/dist/sql-execution-plan-S3HvDKIP-8KF1nBHu.d.mts.map +1 -0
  74. package/dist/{types-BFPRCYGW-Cmlh0DI_.d.mts → types-BFPRCYGW-CvvVz-AC.d.mts} +2 -2
  75. package/dist/{types-BFPRCYGW-Cmlh0DI_.d.mts.map → types-BFPRCYGW-CvvVz-AC.d.mts.map} +1 -1
  76. package/dist/{types-DhYcyD0K-DImmT7YD.d.mts → types-BXSw7th1-pL1Iggyd.d.mts} +8 -2
  77. package/dist/{types-DhYcyD0K-DImmT7YD.d.mts.map → types-BXSw7th1-pL1Iggyd.d.mts.map} +1 -1
  78. package/dist/{types-thCvr3t--B9fvzq0z.d.mts → types-CRU1CBUk-CR2_opbw.d.mts} +6 -6
  79. package/dist/{types-thCvr3t--B9fvzq0z.d.mts.map → types-CRU1CBUk-CR2_opbw.d.mts.map} +1 -1
  80. package/dist/types-RPn42d0t.d.mts +1 -0
  81. package/dist/{types-CWwta5EN-BS4OsQAL.mjs → types-ZNKYVjLr-DzjvSHKB.mjs} +10 -2
  82. package/dist/{types-CWwta5EN-BS4OsQAL.mjs.map → types-ZNKYVjLr-DzjvSHKB.mjs.map} +1 -1
  83. package/package.json +18 -18
  84. package/dist/control-adapter-DjoDaUzQ.d.mts +0 -1
  85. package/dist/middleware-Bef0uiio.d.mts +0 -1
  86. package/dist/plan-BcpzUEU8.d.mts +0 -2
  87. package/dist/plan-oIjoMLQN-VIXmqAKW.d.mts.map +0 -1
  88. package/dist/query-lane-context-C708TwHD.d.mts +0 -1
  89. package/dist/sql-execution-plan-2C68q5Jo-BCQaqOt4.d.mts.map +0 -1
  90. package/dist/types-ZDEZdGgX.d.mts +0 -1
@@ -1,9 +1,9 @@
1
1
  import { t as resolveStorageTable } from "./resolve-storage-table-DZsfnzeW.mjs";
2
2
  import { i as isUniqueConstraintViolation } from "./dist-x6jvtkKM.mjs";
3
- import { C as LiteralExpr, D as OrExpr, F as SubqueryExpr, I as TableSource, L as UpdateAst, O as OrderByItem, P as SelectAst, R as WindowFuncExpr, S as ListExpression, T as NullCheckExpr, U as isWhereExpr, V as isAggregateFn, _ as InsertAst, b as JsonArrayAggExpr, c as DeleteAst, f as EqColJoinOn, j as ProjectionItem, k as ParamRef, l as DerivedTableSource, n as AndExpr, o as ColumnRef, p as ExistsExpr, r as BinaryExpr, s as DefaultValueExpr, t as AggregateExpr, v as InsertOnConflict, w as NotExpr, x as JsonObjectExpr, y as JoinAst } from "./types-CWwta5EN-BS4OsQAL.mjs";
3
+ import { C as LiteralExpr, D as OrExpr, F as SubqueryExpr, I as TableSource, L as UpdateAst, O as OrderByItem, P as SelectAst, R as WindowFuncExpr, S as ListExpression, T as NullCheckExpr, U as isWhereExpr, V as isAggregateFn, _ as InsertAst, b as JsonArrayAggExpr, c as DeleteAst, f as EqColJoinOn, j as ProjectionItem, k as ParamRef, l as DerivedTableSource, n as AndExpr, o as ColumnRef, p as ExistsExpr, r as BinaryExpr, s as DefaultValueExpr, t as AggregateExpr, v as InsertOnConflict, w as NotExpr, x as JsonObjectExpr, y as JoinAst } from "./types-ZNKYVjLr-DzjvSHKB.mjs";
4
4
  import { t as collectOrderedParamRefs } from "./util-DQQgv2j1-D6INZaRG.mjs";
5
- import { n as JsonDocumentProjection, r as NativeJsonValueProjection, t as CodecJsonValueProjection } from "./ast-CS0lZ0OC.mjs";
6
- import { i as isExpression, o as toExpr } from "./expression-CiiHMYqY.mjs";
5
+ import { n as JsonDocumentProjection, r as NativeJsonValueProjection, t as CodecJsonValueProjection } from "./ast-C8jX7HNs.mjs";
6
+ import { i as isExpression, o as toExpr } from "./expression-DqrE3myO.mjs";
7
7
  import { n as codecRefForStorageColumn } from "./codec-descriptor-registry-ECZ4ohtG.mjs";
8
8
  import { structuredError } from "@prisma/orm-framework/utils/structured-error";
9
9
  import { InternalError } from "@prisma/orm-framework/utils/internal-error";
@@ -343,6 +343,29 @@ function assertReturningCapability(contract, action) {
343
343
  action
344
344
  } });
345
345
  }
346
+ function assertInsertConflictSkipCapability(contract, action, targeted) {
347
+ requireCapability(contract, action, "insertOnConflictSkip");
348
+ if (!targeted) requireCapability(contract, action, "insertOnConflictWithoutTarget");
349
+ }
350
+ function requireCapability(contract, action, capability) {
351
+ if (hasContractCapability(contract, capability)) return;
352
+ throw ormError("ORM.CAPABILITY_MISSING", `${action} requires contract capability "${capability}". Re-emit the contract against an adapter that reports it.`, { meta: {
353
+ capability,
354
+ action
355
+ } });
356
+ }
357
+ function resolveInsertConflictColumns(contract, namespaceId, modelName, conflictOn, action) {
358
+ const fieldToColumn = getFieldToColumnMap(contract, namespaceId, modelName);
359
+ return conflictOn.map((fieldName) => {
360
+ const column = fieldToColumn[fieldName];
361
+ if (column === void 0) throw ormError("ORM.ARGUMENT_INVALID", `${action} conflictOn field "${fieldName}" is not a scalar field of model "${modelName}"`, { meta: {
362
+ action,
363
+ model: modelName,
364
+ field: fieldName
365
+ } });
366
+ return column;
367
+ });
368
+ }
346
369
  function assertDistinctOnCapability(contract, methodName) {
347
370
  if (contract.capabilities["postgres"]?.["distinctOn"] === true) return;
348
371
  throw ormError("ORM.CAPABILITY_MISSING", `${methodName}() requires capability postgres.distinctOn`, { meta: {
@@ -1243,15 +1266,20 @@ function normalizeInsertRows(contract, namespaceId, tableName, rows) {
1243
1266
  return normalizedRow;
1244
1267
  }) };
1245
1268
  }
1246
- function compileInsertReturning(contract, namespaceId, tableName, rows, returningColumns) {
1269
+ function conflictSkipClause(tableName, conflictSkip) {
1270
+ if (!conflictSkip) return void 0;
1271
+ if (conflictSkip.columns.length === 0) return InsertOnConflict.doNothing();
1272
+ return InsertOnConflict.on(conflictSkip.columns.map((column) => ColumnRef.of(tableName, column))).doNothing();
1273
+ }
1274
+ function compileInsertReturning(contract, namespaceId, tableName, rows, returningColumns, conflictSkip) {
1247
1275
  const { rows: normalizedRows } = normalizeInsertRows(contract, namespaceId, tableName, rows);
1248
- const ast = InsertAst.into(tableSourceForContract(contract, namespaceId, tableName)).withRows(normalizedRows).withReturning(buildReturningColumns(contract, namespaceId, tableName, returningColumns));
1276
+ const ast = InsertAst.into(tableSourceForContract(contract, namespaceId, tableName)).withRows(normalizedRows).withOnConflict(conflictSkipClause(tableName, conflictSkip)).withReturning(buildReturningColumns(contract, namespaceId, tableName, returningColumns));
1249
1277
  const { params } = deriveParamsFromAst(ast);
1250
1278
  return buildOrmQueryPlan(contract, ast, params);
1251
1279
  }
1252
- function compileInsertCount(contract, namespaceId, tableName, rows) {
1280
+ function compileInsertCount(contract, namespaceId, tableName, rows, conflictSkip) {
1253
1281
  const { rows: normalizedRows } = normalizeInsertRows(contract, namespaceId, tableName, rows);
1254
- const ast = InsertAst.into(tableSourceForContract(contract, namespaceId, tableName)).withRows(normalizedRows);
1282
+ const ast = InsertAst.into(tableSourceForContract(contract, namespaceId, tableName)).withRows(normalizedRows).withOnConflict(conflictSkipClause(tableName, conflictSkip));
1255
1283
  const { params } = deriveParamsFromAst(ast);
1256
1284
  return buildOrmQueryPlan(contract, ast, params);
1257
1285
  }
@@ -1302,21 +1330,21 @@ function groupRowsByColumnSignature(rows) {
1302
1330
  if (currentGroup.length > 0) groups.push(currentGroup);
1303
1331
  return groups;
1304
1332
  }
1305
- function compileInsertReturningSplit(contract, namespaceId, tableName, rows, returningColumns) {
1333
+ function compileInsertReturningSplit(contract, namespaceId, tableName, rows, returningColumns, conflictSkip) {
1306
1334
  if (rows.length === 0) throw ormError("ORM.MUTATION_DATA_MISSING", "create() requires at least one row", { meta: {
1307
1335
  method: "create",
1308
1336
  namespaceId,
1309
1337
  tableName
1310
1338
  } });
1311
- return groupRowsByColumnSignature(rows).map((group) => compileInsertReturning(contract, namespaceId, tableName, group, returningColumns));
1339
+ return groupRowsByColumnSignature(rows).map((group) => compileInsertReturning(contract, namespaceId, tableName, group, returningColumns, conflictSkip));
1312
1340
  }
1313
- function compileInsertCountSplit(contract, namespaceId, tableName, rows) {
1341
+ function compileInsertCountSplit(contract, namespaceId, tableName, rows, conflictSkip) {
1314
1342
  if (rows.length === 0) throw ormError("ORM.MUTATION_DATA_MISSING", "createAndCount() requires at least one row", { meta: {
1315
1343
  method: "createAndCount",
1316
1344
  namespaceId,
1317
1345
  tableName
1318
1346
  } });
1319
- return groupRowsByColumnSignature(rows).map((group) => compileInsertCount(contract, namespaceId, tableName, group));
1347
+ return groupRowsByColumnSignature(rows).map((group) => compileInsertCount(contract, namespaceId, tableName, group, conflictSkip));
1320
1348
  }
1321
1349
  function compileUpsertReturning(contract, namespaceId, tableName, createValues, updateValues, conflictColumns, returningColumns) {
1322
1350
  const createAssignments = toParamAssignments(contract, namespaceId, tableName, createValues);
@@ -3717,6 +3745,16 @@ function isToWhereExprInput(value) {
3717
3745
  function isWhereDirectInput(value) {
3718
3746
  return isWhereExpr(value) && typeof value === "object" && value !== null && "accept" in value && typeof value.accept === "function" || isToWhereExprInput(value);
3719
3747
  }
3748
+ function splitCreateArguments(optionsOrConfigure, configure) {
3749
+ if (typeof optionsOrConfigure === "function") return {
3750
+ options: void 0,
3751
+ configureCallback: optionsOrConfigure
3752
+ };
3753
+ return {
3754
+ options: optionsOrConfigure,
3755
+ configureCallback: configure
3756
+ };
3757
+ }
3720
3758
  function isMtiVariantInfo(variant) {
3721
3759
  return variant?.strategy === "mti";
3722
3760
  }
@@ -4248,16 +4286,26 @@ var CollectionImpl = class CollectionImpl {
4248
4286
  * for await (const row of db.orm.User.createAll(seedUsers)) {
4249
4287
  * console.log('inserted', row.id);
4250
4288
  * }
4289
+ *
4290
+ * // Let the database skip rows that collide with a unique
4291
+ * // constraint; only the rows it inserted come back:
4292
+ * const inserted = await db.orm.User.createAll(seedUsers, {
4293
+ * onConflict: 'skip',
4294
+ * conflictOn: ['email'],
4295
+ * });
4251
4296
  * ```
4252
4297
  *
4253
4298
  * Accepts an optional `configure` callback that receives a
4254
4299
  * `MetaBuilder<'write'>` for attaching typed annotations to the
4255
- * compiled insert plan.
4300
+ * compiled insert plan. It may be passed in second position when
4301
+ * there are no options.
4256
4302
  */
4257
- createAll(data, configure) {
4258
- return this.#createAllWithAnnotations(data, this.#collectAnnotationsFromMeta(configure, "write", "createAll"));
4303
+ createAll(data, optionsOrConfigure, configure) {
4304
+ const { options, configureCallback } = splitCreateArguments(optionsOrConfigure, configure);
4305
+ const conflictSkip = this.#resolveConflictSkip(options, "createAll()");
4306
+ return this.#createAllWithAnnotations(data, this.#collectAnnotationsFromMeta(configureCallback, "write", "createAll"), conflictSkip);
4259
4307
  }
4260
- #createAllWithAnnotations(data, annotationsMap) {
4308
+ #createAllWithAnnotations(data, annotationsMap, conflictSkip) {
4261
4309
  if (data.length === 0) {
4262
4310
  const generator = async function* () {};
4263
4311
  return new AsyncIterableResult(generator());
@@ -4270,7 +4318,7 @@ var CollectionImpl = class CollectionImpl {
4270
4318
  applyCreateDefaults(this.ctx, this.namespaceId, this.tableName, mappedRows);
4271
4319
  const { selectedForQuery: selectedForInsert, hiddenColumns } = this.#augmentMutationSelection();
4272
4320
  if (this.contract.capabilities?.["sql"]?.["defaultInInsert"] !== true) {
4273
- const plans = compileInsertReturningSplit(this.contract, this.namespaceId, this.tableName, mappedRows, selectedForInsert).map((plan) => mergeAnnotations(plan, annotationsMap));
4321
+ const plans = compileInsertReturningSplit(this.contract, this.namespaceId, this.tableName, mappedRows, selectedForInsert, conflictSkip).map((plan) => mergeAnnotations(plan, annotationsMap));
4274
4322
  return dispatchSplitMutationRows({
4275
4323
  context: this.ctx.context,
4276
4324
  runtime: this.ctx.runtime,
@@ -4285,7 +4333,7 @@ var CollectionImpl = class CollectionImpl {
4285
4333
  mapRow: (mapped) => blindCast(mapped)
4286
4334
  });
4287
4335
  }
4288
- const compiled = mergeAnnotations(compileInsertReturning(this.contract, this.namespaceId, this.tableName, mappedRows, selectedForInsert), annotationsMap);
4336
+ const compiled = mergeAnnotations(compileInsertReturning(this.contract, this.namespaceId, this.tableName, mappedRows, selectedForInsert, conflictSkip), annotationsMap);
4289
4337
  return dispatchMutationRows({
4290
4338
  context: this.ctx.context,
4291
4339
  runtime: this.ctx.runtime,
@@ -4300,6 +4348,17 @@ var CollectionImpl = class CollectionImpl {
4300
4348
  mapRow: (mapped) => blindCast(mapped)
4301
4349
  });
4302
4350
  }
4351
+ #resolveConflictSkip(options, method) {
4352
+ if (options === void 0) return void 0;
4353
+ if (options.onConflict !== "skip") throw ormError("ORM.ARGUMENT_INVALID", `${method} onConflict must be "skip"; received ${JSON.stringify(options.onConflict)}`, { meta: {
4354
+ method,
4355
+ model: this.modelName
4356
+ } });
4357
+ this.#assertNotMtiVariant(method);
4358
+ const conflictOn = options.conflictOn ?? [];
4359
+ assertInsertConflictSkipCapability(this.contract, method, conflictOn.length > 0);
4360
+ return { columns: resolveInsertConflictColumns(this.contract, this.namespaceId, this.modelName, conflictOn, method) };
4361
+ }
4303
4362
  #assertNotMtiVariant(method) {
4304
4363
  if (this.#resolveMtiCreateContext()) throw ormError("ORM.OPERATION_UNSUPPORTED", `${method} is not supported for MTI variant "${this.state.variantName}" on model "${this.modelName}". Use createAll() instead.`, { meta: {
4305
4364
  method,
@@ -4412,7 +4471,8 @@ var CollectionImpl = class CollectionImpl {
4412
4471
  }
4413
4472
  /**
4414
4473
  * Write terminal: insert many rows without materializing the
4415
- * inserted rows, returning the number of inserted records.
4474
+ * inserted rows, returning the number of rows the database reports
4475
+ * inserting.
4416
4476
  *
4417
4477
  * Prefer `createAll(...)` when you need the returned rows; prefer
4418
4478
  * this when you only need to know how many rows were inserted (the
@@ -4424,25 +4484,36 @@ var CollectionImpl = class CollectionImpl {
4424
4484
  * { email: 'b@example.com' },
4425
4485
  * ]);
4426
4486
  * // inserted === 2
4487
+ *
4488
+ * // Let the database skip rows that collide with a unique
4489
+ * // constraint; the count is how many it actually inserted:
4490
+ * const added = await db.orm.User.createAndCount(seedUsers, {
4491
+ * onConflict: 'skip',
4492
+ * });
4427
4493
  * ```
4428
4494
  *
4429
4495
  * Not supported on MTI variants — use `createAll(...)` instead.
4430
4496
  */
4431
- async createAndCount(data, configure) {
4497
+ async createAndCount(data, optionsOrConfigure, configure) {
4498
+ const { options, configureCallback } = splitCreateArguments(optionsOrConfigure, configure);
4499
+ const conflictSkip = this.#resolveConflictSkip(options, "createAndCount()");
4432
4500
  if (data.length === 0) return 0;
4433
4501
  this.#assertNotMtiVariant("createAndCount()");
4434
- const annotationsMap = this.#collectAnnotationsFromMeta(configure, "write", "createAndCount");
4502
+ const annotationsMap = this.#collectAnnotationsFromMeta(configureCallback, "write", "createAndCount");
4435
4503
  const rows = blindCast(data);
4436
4504
  const mappedRows = this.#mapCreateRows(rows);
4437
4505
  applyCreateDefaults(this.ctx, this.namespaceId, this.tableName, mappedRows);
4438
4506
  if (this.contract.capabilities?.["sql"]?.["defaultInInsert"] !== true) {
4439
- const plans = compileInsertCountSplit(this.contract, this.namespaceId, this.tableName, mappedRows).map((plan) => mergeAnnotations(plan, annotationsMap));
4440
- for (const plan of plans) await this.ctx.runtime.execute(plan);
4441
- return data.length;
4507
+ const plans = compileInsertCountSplit(this.contract, this.namespaceId, this.tableName, mappedRows, conflictSkip).map((plan) => mergeAnnotations(plan, annotationsMap));
4508
+ let affectedRows = 0;
4509
+ for (const plan of plans) {
4510
+ const stats = await this.ctx.runtime.execute(plan);
4511
+ affectedRows += stats.affectedRows;
4512
+ }
4513
+ return affectedRows;
4442
4514
  }
4443
- const compiled = mergeAnnotations(compileInsertCount(this.contract, this.namespaceId, this.tableName, mappedRows), annotationsMap);
4444
- await this.ctx.runtime.execute(compiled);
4445
- return data.length;
4515
+ const compiled = mergeAnnotations(compileInsertCount(this.contract, this.namespaceId, this.tableName, mappedRows, conflictSkip), annotationsMap);
4516
+ return (await this.ctx.runtime.execute(compiled)).affectedRows;
4446
4517
  }
4447
4518
  /**
4448
4519
  * Write terminal: insert a row, or update the existing row on