@prisma/client-engine-runtime 6.9.0 → 6.10.0-dev.10

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.
@@ -100,6 +100,9 @@ export type JoinExpression = {
100
100
  isRelationUnique: boolean;
101
101
  };
102
102
  export type QueryPlanNode = {
103
+ type: 'value';
104
+ args: PrismaValue;
105
+ } | {
103
106
  type: 'seq';
104
107
  args: QueryPlanNode[];
105
108
  } | {
@@ -196,17 +199,40 @@ export type QueryPlanNode = {
196
199
  pagination: Pagination;
197
200
  };
198
201
  } | {
199
- type: 'extendRecord';
202
+ type: 'initializeRecord';
203
+ args: {
204
+ expr: QueryPlanNode;
205
+ fields: Record<string, FieldInitializer>;
206
+ };
207
+ } | {
208
+ type: 'mapRecord';
200
209
  args: {
201
210
  expr: QueryPlanNode;
202
- values: Record<string, {
203
- type: 'value';
204
- value: PrismaValue;
205
- } | {
206
- type: 'lastInsertId';
207
- }>;
211
+ fields: Record<string, FieldOperation>;
208
212
  };
209
213
  };
214
+ export type FieldInitializer = {
215
+ type: 'value';
216
+ value: PrismaValue;
217
+ } | {
218
+ type: 'lastInsertId';
219
+ };
220
+ export type FieldOperation = {
221
+ type: 'set';
222
+ value: PrismaValue;
223
+ } | {
224
+ type: 'add';
225
+ value: PrismaValue;
226
+ } | {
227
+ type: 'subtract';
228
+ value: PrismaValue;
229
+ } | {
230
+ type: 'multiply';
231
+ value: PrismaValue;
232
+ } | {
233
+ type: 'divide';
234
+ value: PrismaValue;
235
+ };
210
236
  export type Pagination = {
211
237
  cursor: Record<string, PrismaValue> | null;
212
238
  take: number | null;
package/dist/index.d.mts CHANGED
@@ -35,6 +35,30 @@ declare type ExtendedSpanOptions = SpanOptions & {
35
35
  name: string;
36
36
  };
37
37
 
38
+ export declare type FieldInitializer = {
39
+ type: 'value';
40
+ value: PrismaValue;
41
+ } | {
42
+ type: 'lastInsertId';
43
+ };
44
+
45
+ export declare type FieldOperation = {
46
+ type: 'set';
47
+ value: PrismaValue;
48
+ } | {
49
+ type: 'add';
50
+ value: PrismaValue;
51
+ } | {
52
+ type: 'subtract';
53
+ value: PrismaValue;
54
+ } | {
55
+ type: 'multiply';
56
+ value: PrismaValue;
57
+ } | {
58
+ type: 'divide';
59
+ value: PrismaValue;
60
+ };
61
+
38
62
  export declare type Fragment = {
39
63
  type: 'stringChunk';
40
64
  value: string;
@@ -191,6 +215,9 @@ export declare type QueryPlanDbQuery = {
191
215
  };
192
216
 
193
217
  export declare type QueryPlanNode = {
218
+ type: 'value';
219
+ args: PrismaValue;
220
+ } | {
194
221
  type: 'seq';
195
222
  args: QueryPlanNode[];
196
223
  } | {
@@ -287,15 +314,16 @@ export declare type QueryPlanNode = {
287
314
  pagination: Pagination;
288
315
  };
289
316
  } | {
290
- type: 'extendRecord';
317
+ type: 'initializeRecord';
318
+ args: {
319
+ expr: QueryPlanNode;
320
+ fields: Record<string, FieldInitializer>;
321
+ };
322
+ } | {
323
+ type: 'mapRecord';
291
324
  args: {
292
325
  expr: QueryPlanNode;
293
- values: Record<string, {
294
- type: 'value';
295
- value: PrismaValue;
296
- } | {
297
- type: 'lastInsertId';
298
- }>;
326
+ fields: Record<string, FieldOperation>;
299
327
  };
300
328
  };
301
329
 
package/dist/index.d.ts CHANGED
@@ -35,6 +35,30 @@ declare type ExtendedSpanOptions = SpanOptions & {
35
35
  name: string;
36
36
  };
37
37
 
38
+ export declare type FieldInitializer = {
39
+ type: 'value';
40
+ value: PrismaValue;
41
+ } | {
42
+ type: 'lastInsertId';
43
+ };
44
+
45
+ export declare type FieldOperation = {
46
+ type: 'set';
47
+ value: PrismaValue;
48
+ } | {
49
+ type: 'add';
50
+ value: PrismaValue;
51
+ } | {
52
+ type: 'subtract';
53
+ value: PrismaValue;
54
+ } | {
55
+ type: 'multiply';
56
+ value: PrismaValue;
57
+ } | {
58
+ type: 'divide';
59
+ value: PrismaValue;
60
+ };
61
+
38
62
  export declare type Fragment = {
39
63
  type: 'stringChunk';
40
64
  value: string;
@@ -191,6 +215,9 @@ export declare type QueryPlanDbQuery = {
191
215
  };
192
216
 
193
217
  export declare type QueryPlanNode = {
218
+ type: 'value';
219
+ args: PrismaValue;
220
+ } | {
194
221
  type: 'seq';
195
222
  args: QueryPlanNode[];
196
223
  } | {
@@ -287,15 +314,16 @@ export declare type QueryPlanNode = {
287
314
  pagination: Pagination;
288
315
  };
289
316
  } | {
290
- type: 'extendRecord';
317
+ type: 'initializeRecord';
318
+ args: {
319
+ expr: QueryPlanNode;
320
+ fields: Record<string, FieldInitializer>;
321
+ };
322
+ } | {
323
+ type: 'mapRecord';
291
324
  args: {
292
325
  expr: QueryPlanNode;
293
- values: Record<string, {
294
- type: 'value';
295
- value: PrismaValue;
296
- } | {
297
- type: 'lastInsertId';
298
- }>;
326
+ fields: Record<string, FieldOperation>;
299
327
  };
300
328
  };
301
329
 
package/dist/index.js CHANGED
@@ -403,12 +403,16 @@ function getErrorCode(err) {
403
403
  return "P2010";
404
404
  case "NullConstraintViolation":
405
405
  return "P2011";
406
+ case "ValueOutOfRange":
407
+ return "P2020";
406
408
  case "TableDoesNotExist":
407
409
  return "P2021";
408
410
  case "ColumnNotFound":
409
411
  return "P2022";
410
412
  case "InvalidIsolationLevel":
411
413
  return "P2023";
414
+ case "MissingFullTextSearchIndex":
415
+ return "P2030";
412
416
  case "TransactionWriteConflict":
413
417
  return "P2034";
414
418
  case "GenericJs":
@@ -448,13 +452,15 @@ function renderErrorMessage(err) {
448
452
  return `The provided value for the column is too long for the column's type. Column: ${column}`;
449
453
  }
450
454
  case "UniqueConstraintViolation":
451
- return `Unique constraint failed on the ${renderConstraint({ fields: err.cause.fields })}`;
455
+ return `Unique constraint failed on the ${renderConstraint(err.cause.constraint)}`;
452
456
  case "ForeignKeyConstraintViolation":
453
457
  return `Foreign key constraint violated on the ${renderConstraint(err.cause.constraint)}`;
454
458
  case "UnsupportedNativeDataType":
455
459
  return `Failed to deserialize column of type '${err.cause.type}'. If you're using $queryRaw and this column is explicitly marked as \`Unsupported\` in your Prisma schema, try casting this column to any supported Prisma type such as \`String\`.`;
456
460
  case "NullConstraintViolation":
457
- return `Null constraint violation on the ${renderConstraint({ fields: err.cause.fields })}`;
461
+ return `Null constraint violation on the ${renderConstraint(err.cause.constraint)}`;
462
+ case "ValueOutOfRange":
463
+ return `Value out of range for the type. ${err.cause.cause}`;
458
464
  case "TableDoesNotExist": {
459
465
  const table = err.cause.table ?? "(not available)";
460
466
  return `The table \`${table}\` does not exist in the current database.`;
@@ -465,6 +471,8 @@ function renderErrorMessage(err) {
465
471
  }
466
472
  case "InvalidIsolationLevel":
467
473
  return `Invalid isolation level \`${err.cause.level}\``;
474
+ case "MissingFullTextSearchIndex":
475
+ return "Cannot find a fulltext index to use for the native search, try adding a @@fulltext([Fields...]) to your schema";
468
476
  case "TransactionWriteConflict":
469
477
  return `Transaction failed due to a write conflict or a deadlock. Please retry your transaction`;
470
478
  case "GenericJs":
@@ -975,6 +983,9 @@ var QueryInterpreter = class _QueryInterpreter {
975
983
  }
976
984
  async interpretNode(node, queryable, scope, generators) {
977
985
  switch (node.type) {
986
+ case "value": {
987
+ return { value: evaluateParam(node.args, scope, generators) };
988
+ }
978
989
  case "seq": {
979
990
  let result;
980
991
  for (const arg of node.args) {
@@ -1156,15 +1167,19 @@ var QueryInterpreter = class _QueryInterpreter {
1156
1167
  }
1157
1168
  return { value: paginate(list, node.args.pagination), lastInsertId };
1158
1169
  }
1159
- case "extendRecord": {
1170
+ case "initializeRecord": {
1171
+ const { lastInsertId } = await this.interpretNode(node.args.expr, queryable, scope, generators);
1172
+ const record = {};
1173
+ for (const [key, initializer] of Object.entries(node.args.fields)) {
1174
+ record[key] = evalFieldInitializer(initializer, lastInsertId, scope, generators);
1175
+ }
1176
+ return { value: record, lastInsertId };
1177
+ }
1178
+ case "mapRecord": {
1160
1179
  const { value, lastInsertId } = await this.interpretNode(node.args.expr, queryable, scope, generators);
1161
1180
  const record = value === null ? {} : asRecord(value);
1162
- for (const [key, entry] of Object.entries(node.args.values)) {
1163
- if (entry.type === "lastInsertId") {
1164
- record[key] = lastInsertId;
1165
- } else {
1166
- record[key] = evaluateParam(entry.value, scope, generators);
1167
- }
1181
+ for (const [key, entry] of Object.entries(node.args.fields)) {
1182
+ record[key] = evalFieldOperation(entry, record[key], scope, generators);
1168
1183
  }
1169
1184
  return { value: record, lastInsertId };
1170
1185
  }
@@ -1256,6 +1271,38 @@ function paginate(list, { cursor, skip, take }) {
1256
1271
  function getRecordKey(record, fields) {
1257
1272
  return JSON.stringify(fields.map((field) => record[field]));
1258
1273
  }
1274
+ function evalFieldInitializer(initializer, lastInsertId, scope, generators) {
1275
+ switch (initializer.type) {
1276
+ case "value":
1277
+ return evaluateParam(initializer.value, scope, generators);
1278
+ case "lastInsertId":
1279
+ return lastInsertId;
1280
+ default:
1281
+ assertNever(initializer, `Unexpected field initializer type: ${initializer["type"]}`);
1282
+ }
1283
+ }
1284
+ function evalFieldOperation(op, value, scope, generators) {
1285
+ switch (op.type) {
1286
+ case "set":
1287
+ return evaluateParam(op.value, scope, generators);
1288
+ case "add":
1289
+ return asNumber(value) + asNumber(evaluateParam(op.value, scope, generators));
1290
+ case "subtract":
1291
+ return asNumber(value) - asNumber(evaluateParam(op.value, scope, generators));
1292
+ case "multiply":
1293
+ return asNumber(value) * asNumber(evaluateParam(op.value, scope, generators));
1294
+ case "divide": {
1295
+ const lhs = asNumber(value);
1296
+ const rhs = asNumber(evaluateParam(op.value, scope, generators));
1297
+ if (rhs === 0) {
1298
+ return null;
1299
+ }
1300
+ return lhs / rhs;
1301
+ }
1302
+ default:
1303
+ assertNever(op, `Unexpected field operation type: ${op["type"]}`);
1304
+ }
1305
+ }
1259
1306
 
1260
1307
  // src/transactionManager/TransactionManager.ts
1261
1308
  var import_debug = require("@prisma/debug");
package/dist/index.mjs CHANGED
@@ -355,12 +355,16 @@ function getErrorCode(err) {
355
355
  return "P2010";
356
356
  case "NullConstraintViolation":
357
357
  return "P2011";
358
+ case "ValueOutOfRange":
359
+ return "P2020";
358
360
  case "TableDoesNotExist":
359
361
  return "P2021";
360
362
  case "ColumnNotFound":
361
363
  return "P2022";
362
364
  case "InvalidIsolationLevel":
363
365
  return "P2023";
366
+ case "MissingFullTextSearchIndex":
367
+ return "P2030";
364
368
  case "TransactionWriteConflict":
365
369
  return "P2034";
366
370
  case "GenericJs":
@@ -400,13 +404,15 @@ function renderErrorMessage(err) {
400
404
  return `The provided value for the column is too long for the column's type. Column: ${column}`;
401
405
  }
402
406
  case "UniqueConstraintViolation":
403
- return `Unique constraint failed on the ${renderConstraint({ fields: err.cause.fields })}`;
407
+ return `Unique constraint failed on the ${renderConstraint(err.cause.constraint)}`;
404
408
  case "ForeignKeyConstraintViolation":
405
409
  return `Foreign key constraint violated on the ${renderConstraint(err.cause.constraint)}`;
406
410
  case "UnsupportedNativeDataType":
407
411
  return `Failed to deserialize column of type '${err.cause.type}'. If you're using $queryRaw and this column is explicitly marked as \`Unsupported\` in your Prisma schema, try casting this column to any supported Prisma type such as \`String\`.`;
408
412
  case "NullConstraintViolation":
409
- return `Null constraint violation on the ${renderConstraint({ fields: err.cause.fields })}`;
413
+ return `Null constraint violation on the ${renderConstraint(err.cause.constraint)}`;
414
+ case "ValueOutOfRange":
415
+ return `Value out of range for the type. ${err.cause.cause}`;
410
416
  case "TableDoesNotExist": {
411
417
  const table = err.cause.table ?? "(not available)";
412
418
  return `The table \`${table}\` does not exist in the current database.`;
@@ -417,6 +423,8 @@ function renderErrorMessage(err) {
417
423
  }
418
424
  case "InvalidIsolationLevel":
419
425
  return `Invalid isolation level \`${err.cause.level}\``;
426
+ case "MissingFullTextSearchIndex":
427
+ return "Cannot find a fulltext index to use for the native search, try adding a @@fulltext([Fields...]) to your schema";
420
428
  case "TransactionWriteConflict":
421
429
  return `Transaction failed due to a write conflict or a deadlock. Please retry your transaction`;
422
430
  case "GenericJs":
@@ -927,6 +935,9 @@ var QueryInterpreter = class _QueryInterpreter {
927
935
  }
928
936
  async interpretNode(node, queryable, scope, generators) {
929
937
  switch (node.type) {
938
+ case "value": {
939
+ return { value: evaluateParam(node.args, scope, generators) };
940
+ }
930
941
  case "seq": {
931
942
  let result;
932
943
  for (const arg of node.args) {
@@ -1108,15 +1119,19 @@ var QueryInterpreter = class _QueryInterpreter {
1108
1119
  }
1109
1120
  return { value: paginate(list, node.args.pagination), lastInsertId };
1110
1121
  }
1111
- case "extendRecord": {
1122
+ case "initializeRecord": {
1123
+ const { lastInsertId } = await this.interpretNode(node.args.expr, queryable, scope, generators);
1124
+ const record = {};
1125
+ for (const [key, initializer] of Object.entries(node.args.fields)) {
1126
+ record[key] = evalFieldInitializer(initializer, lastInsertId, scope, generators);
1127
+ }
1128
+ return { value: record, lastInsertId };
1129
+ }
1130
+ case "mapRecord": {
1112
1131
  const { value, lastInsertId } = await this.interpretNode(node.args.expr, queryable, scope, generators);
1113
1132
  const record = value === null ? {} : asRecord(value);
1114
- for (const [key, entry] of Object.entries(node.args.values)) {
1115
- if (entry.type === "lastInsertId") {
1116
- record[key] = lastInsertId;
1117
- } else {
1118
- record[key] = evaluateParam(entry.value, scope, generators);
1119
- }
1133
+ for (const [key, entry] of Object.entries(node.args.fields)) {
1134
+ record[key] = evalFieldOperation(entry, record[key], scope, generators);
1120
1135
  }
1121
1136
  return { value: record, lastInsertId };
1122
1137
  }
@@ -1208,6 +1223,38 @@ function paginate(list, { cursor, skip, take }) {
1208
1223
  function getRecordKey(record, fields) {
1209
1224
  return JSON.stringify(fields.map((field) => record[field]));
1210
1225
  }
1226
+ function evalFieldInitializer(initializer, lastInsertId, scope, generators) {
1227
+ switch (initializer.type) {
1228
+ case "value":
1229
+ return evaluateParam(initializer.value, scope, generators);
1230
+ case "lastInsertId":
1231
+ return lastInsertId;
1232
+ default:
1233
+ assertNever(initializer, `Unexpected field initializer type: ${initializer["type"]}`);
1234
+ }
1235
+ }
1236
+ function evalFieldOperation(op, value, scope, generators) {
1237
+ switch (op.type) {
1238
+ case "set":
1239
+ return evaluateParam(op.value, scope, generators);
1240
+ case "add":
1241
+ return asNumber(value) + asNumber(evaluateParam(op.value, scope, generators));
1242
+ case "subtract":
1243
+ return asNumber(value) - asNumber(evaluateParam(op.value, scope, generators));
1244
+ case "multiply":
1245
+ return asNumber(value) * asNumber(evaluateParam(op.value, scope, generators));
1246
+ case "divide": {
1247
+ const lhs = asNumber(value);
1248
+ const rhs = asNumber(evaluateParam(op.value, scope, generators));
1249
+ if (rhs === 0) {
1250
+ return null;
1251
+ }
1252
+ return lhs / rhs;
1253
+ }
1254
+ default:
1255
+ assertNever(op, `Unexpected field operation type: ${op["type"]}`);
1256
+ }
1257
+ }
1211
1258
 
1212
1259
  // src/transactionManager/TransactionManager.ts
1213
1260
  import { Debug } from "@prisma/debug";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prisma/client-engine-runtime",
3
- "version": "6.9.0",
3
+ "version": "6.10.0-dev.10",
4
4
  "description": "This package is intended for Prisma's internal use",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -31,8 +31,8 @@
31
31
  "nanoid": "5.1.5",
32
32
  "ulid": "3.0.0",
33
33
  "uuid": "11.1.0",
34
- "@prisma/debug": "6.9.0",
35
- "@prisma/driver-adapter-utils": "6.9.0"
34
+ "@prisma/debug": "6.10.0-dev.10",
35
+ "@prisma/driver-adapter-utils": "6.10.0-dev.10"
36
36
  },
37
37
  "devDependencies": {
38
38
  "@types/jest": "29.5.14",