@prisma/client-engine-runtime 6.12.0-dev.2 → 6.12.0-dev.21

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.d.mts CHANGED
@@ -175,12 +175,13 @@ export declare type QueryEvent = {
175
175
 
176
176
  export declare class QueryInterpreter {
177
177
  #private;
178
- constructor({ transactionManager, placeholderValues, onQuery, tracingHelper, serializer, rawSerializer, }: QueryInterpreterOptions);
178
+ constructor({ transactionManager, placeholderValues, onQuery, tracingHelper, serializer, rawSerializer, provider, }: QueryInterpreterOptions);
179
179
  static forSql(options: {
180
180
  transactionManager: QueryInterpreterTransactionManager;
181
181
  placeholderValues: Record<string, unknown>;
182
182
  onQuery?: (event: QueryEvent) => void;
183
183
  tracingHelper: TracingHelper;
184
+ provider?: SchemaProvider;
184
185
  }): QueryInterpreter;
185
186
  run(queryPlan: QueryPlanNode, queryable: SqlQueryable): Promise<unknown>;
186
187
  private interpretNode;
@@ -193,6 +194,7 @@ export declare type QueryInterpreterOptions = {
193
194
  tracingHelper: TracingHelper;
194
195
  serializer: (results: SqlResultSet) => Value;
195
196
  rawSerializer?: (results: SqlResultSet) => Value;
197
+ provider?: SchemaProvider;
196
198
  };
197
199
 
198
200
  export declare type QueryInterpreterTransactionManager = {
@@ -349,6 +351,11 @@ export declare type ResultNode = {
349
351
  */
350
352
  export declare function safeJsonStringify(obj: unknown): string;
351
353
 
354
+ /**
355
+ * `provider` property as defined in Prisma Schema (may differ from {@link @prisma/driver-adapter-utils#Provider}).
356
+ */
357
+ export declare type SchemaProvider = 'cockroachdb' | 'mongodb' | 'mysql' | 'postgres' | 'postgresql' | 'prisma+postgres' | 'sqlite' | 'sqlserver';
358
+
352
359
  declare type SpanCallback<R> = (span?: Span, context?: Context) => R;
353
360
 
354
361
  export declare interface TracingHelper {
@@ -366,11 +373,12 @@ export declare class TransactionManager {
366
373
  private readonly driverAdapter;
367
374
  private readonly transactionOptions;
368
375
  private readonly tracingHelper;
369
- constructor({ driverAdapter, transactionOptions, tracingHelper, onQuery, }: {
376
+ constructor({ driverAdapter, transactionOptions, tracingHelper, onQuery, provider, }: {
370
377
  driverAdapter: SqlDriverAdapter;
371
378
  transactionOptions: TransactionOptions;
372
379
  tracingHelper: TracingHelper;
373
380
  onQuery?: (event: QueryEvent) => void;
381
+ provider?: SchemaProvider;
374
382
  });
375
383
  startTransaction(options?: TransactionOptions): Promise<TransactionInfo>;
376
384
  commitTransaction(transactionId: string): Promise<void>;
package/dist/index.d.ts CHANGED
@@ -175,12 +175,13 @@ export declare type QueryEvent = {
175
175
 
176
176
  export declare class QueryInterpreter {
177
177
  #private;
178
- constructor({ transactionManager, placeholderValues, onQuery, tracingHelper, serializer, rawSerializer, }: QueryInterpreterOptions);
178
+ constructor({ transactionManager, placeholderValues, onQuery, tracingHelper, serializer, rawSerializer, provider, }: QueryInterpreterOptions);
179
179
  static forSql(options: {
180
180
  transactionManager: QueryInterpreterTransactionManager;
181
181
  placeholderValues: Record<string, unknown>;
182
182
  onQuery?: (event: QueryEvent) => void;
183
183
  tracingHelper: TracingHelper;
184
+ provider?: SchemaProvider;
184
185
  }): QueryInterpreter;
185
186
  run(queryPlan: QueryPlanNode, queryable: SqlQueryable): Promise<unknown>;
186
187
  private interpretNode;
@@ -193,6 +194,7 @@ export declare type QueryInterpreterOptions = {
193
194
  tracingHelper: TracingHelper;
194
195
  serializer: (results: SqlResultSet) => Value;
195
196
  rawSerializer?: (results: SqlResultSet) => Value;
197
+ provider?: SchemaProvider;
196
198
  };
197
199
 
198
200
  export declare type QueryInterpreterTransactionManager = {
@@ -349,6 +351,11 @@ export declare type ResultNode = {
349
351
  */
350
352
  export declare function safeJsonStringify(obj: unknown): string;
351
353
 
354
+ /**
355
+ * `provider` property as defined in Prisma Schema (may differ from {@link @prisma/driver-adapter-utils#Provider}).
356
+ */
357
+ export declare type SchemaProvider = 'cockroachdb' | 'mongodb' | 'mysql' | 'postgres' | 'postgresql' | 'prisma+postgres' | 'sqlite' | 'sqlserver';
358
+
352
359
  declare type SpanCallback<R> = (span?: Span, context?: Context) => R;
353
360
 
354
361
  export declare interface TracingHelper {
@@ -366,11 +373,12 @@ export declare class TransactionManager {
366
373
  private readonly driverAdapter;
367
374
  private readonly transactionOptions;
368
375
  private readonly tracingHelper;
369
- constructor({ driverAdapter, transactionOptions, tracingHelper, onQuery, }: {
376
+ constructor({ driverAdapter, transactionOptions, tracingHelper, onQuery, provider, }: {
370
377
  driverAdapter: SqlDriverAdapter;
371
378
  transactionOptions: TransactionOptions;
372
379
  tracingHelper: TracingHelper;
373
380
  onQuery?: (event: QueryEvent) => void;
381
+ provider?: SchemaProvider;
374
382
  });
375
383
  startTransaction(options?: TransactionOptions): Promise<TransactionInfo>;
376
384
  commitTransaction(transactionId: string): Promise<void>;
package/dist/index.js CHANGED
@@ -62,20 +62,74 @@ function doKeysMatch(lhs, rhs) {
62
62
  const rhsKeys = Object.keys(rhs);
63
63
  const smallerKeyList = lhsKeys.length < rhsKeys.length ? lhsKeys : rhsKeys;
64
64
  return smallerKeyList.every((key) => {
65
- if (typeof lhs[key] !== typeof rhs[key]) {
66
- if (typeof lhs[key] === "number" || typeof rhs[key] === "number") {
67
- return `${lhs[key]}` === `${rhs[key]}`;
68
- } else if (typeof lhs[key] === "bigint" || typeof rhs[key] === "bigint") {
69
- return BigInt(`${lhs[key]}`.replace(/n$/, "")) === BigInt(`${rhs[key]}`.replace(/n$/, ""));
70
- } else if (lhs[key] instanceof Date || rhs[key] instanceof Date) {
71
- return (/* @__PURE__ */ new Date(`${lhs[key]}`)).getTime() === (/* @__PURE__ */ new Date(`${rhs[key]}`)).getTime();
72
- } else if (import_decimal.default.isDecimal(lhs[key]) || import_decimal.default.isDecimal(rhs[key])) {
73
- return new import_decimal.default(`${lhs[key]}`).equals(new import_decimal.default(`${rhs[key]}`));
74
- }
65
+ if (typeof lhs[key] === typeof rhs[key] && typeof lhs[key] !== "object") {
66
+ return lhs[key] === rhs[key];
67
+ }
68
+ if (import_decimal.default.isDecimal(lhs[key]) || import_decimal.default.isDecimal(rhs[key])) {
69
+ const lhsDecimal = asDecimal(lhs[key]);
70
+ const rhsDecimal = asDecimal(rhs[key]);
71
+ return lhsDecimal && rhsDecimal && lhsDecimal.equals(rhsDecimal);
72
+ } else if (lhs[key] instanceof Uint8Array || rhs[key] instanceof Uint8Array) {
73
+ const lhsBuffer = asBuffer(lhs[key]);
74
+ const rhsBuffer = asBuffer(rhs[key]);
75
+ return lhsBuffer && rhsBuffer && lhsBuffer.equals(rhsBuffer);
76
+ } else if (lhs[key] instanceof Date || rhs[key] instanceof Date) {
77
+ return asDate(lhs[key])?.getTime() === asDate(rhs[key])?.getTime();
78
+ } else if (typeof lhs[key] === "bigint" || typeof rhs[key] === "bigint") {
79
+ return asBigInt(lhs[key]) === asBigInt(rhs[key]);
80
+ } else if (typeof lhs[key] === "number" || typeof rhs[key] === "number") {
81
+ return asNumber(lhs[key]) === asNumber(rhs[key]);
75
82
  }
76
83
  return isDeepStrictEqual(lhs[key], rhs[key]);
77
84
  });
78
85
  }
86
+ function asDecimal(value) {
87
+ if (import_decimal.default.isDecimal(value)) {
88
+ return value;
89
+ } else if (typeof value === "number" || typeof value === "string") {
90
+ return new import_decimal.default(value);
91
+ } else {
92
+ return;
93
+ }
94
+ }
95
+ function asBuffer(value) {
96
+ if (Buffer.isBuffer(value)) {
97
+ return value;
98
+ } else if (value instanceof Uint8Array) {
99
+ return Buffer.from(value.buffer, value.byteOffset, value.byteLength);
100
+ } else if (typeof value === "string") {
101
+ return Buffer.from(value, "base64");
102
+ } else {
103
+ return;
104
+ }
105
+ }
106
+ function asDate(value) {
107
+ if (value instanceof Date) {
108
+ return value;
109
+ } else if (typeof value === "string" || typeof value === "number") {
110
+ return new Date(value);
111
+ } else {
112
+ return;
113
+ }
114
+ }
115
+ function asBigInt(value) {
116
+ if (typeof value === "bigint") {
117
+ return value;
118
+ } else if (typeof value === "number" || typeof value === "string") {
119
+ return BigInt(value);
120
+ } else {
121
+ return;
122
+ }
123
+ }
124
+ function asNumber(value) {
125
+ if (typeof value === "number") {
126
+ return value;
127
+ } else if (typeof value === "string") {
128
+ return Number(value);
129
+ } else {
130
+ return;
131
+ }
132
+ }
79
133
  function safeJsonStringify(obj) {
80
134
  return JSON.stringify(obj, (_key, val) => {
81
135
  if (typeof val === "bigint") {
@@ -314,22 +368,25 @@ var noopTracingHelper = {
314
368
  };
315
369
  function providerToOtelSystem(provider) {
316
370
  switch (provider) {
371
+ case "postgresql":
317
372
  case "postgres":
373
+ case "prisma+postgres":
318
374
  return "postgresql";
319
- case "mysql":
320
- return "mysql";
321
- case "sqlite":
322
- return "sqlite";
323
375
  case "sqlserver":
324
376
  return "mssql";
377
+ case "mysql":
378
+ case "sqlite":
379
+ case "cockroachdb":
380
+ case "mongodb":
381
+ return provider;
325
382
  default:
326
383
  assertNever(provider, `Unknown provider: ${provider}`);
327
384
  }
328
385
  }
329
386
  async function withQuerySpanAndEvent({
330
387
  query,
331
- queryable,
332
388
  tracingHelper,
389
+ provider,
333
390
  onQuery,
334
391
  execute
335
392
  }) {
@@ -339,7 +396,7 @@ async function withQuerySpanAndEvent({
339
396
  kind: import_api.SpanKind.CLIENT,
340
397
  attributes: {
341
398
  "db.query.text": query.sql,
342
- "db.system.name": providerToOtelSystem(queryable.provider)
399
+ "db.system.name": providerToOtelSystem(provider)
343
400
  }
344
401
  },
345
402
  async () => {
@@ -977,13 +1034,15 @@ var QueryInterpreter = class _QueryInterpreter {
977
1034
  #tracingHelper;
978
1035
  #serializer;
979
1036
  #rawSerializer;
1037
+ #provider;
980
1038
  constructor({
981
1039
  transactionManager,
982
1040
  placeholderValues,
983
1041
  onQuery,
984
1042
  tracingHelper,
985
1043
  serializer,
986
- rawSerializer
1044
+ rawSerializer,
1045
+ provider
987
1046
  }) {
988
1047
  this.#transactionManager = transactionManager;
989
1048
  this.#placeholderValues = placeholderValues;
@@ -991,6 +1050,7 @@ var QueryInterpreter = class _QueryInterpreter {
991
1050
  this.#tracingHelper = tracingHelper;
992
1051
  this.#serializer = serializer;
993
1052
  this.#rawSerializer = rawSerializer ?? serializer;
1053
+ this.#provider = provider;
994
1054
  }
995
1055
  static forSql(options) {
996
1056
  return new _QueryInterpreter({
@@ -999,7 +1059,8 @@ var QueryInterpreter = class _QueryInterpreter {
999
1059
  onQuery: options.onQuery,
1000
1060
  tracingHelper: options.tracingHelper,
1001
1061
  serializer: serializeSql,
1002
- rawSerializer: serializeRawSql
1062
+ rawSerializer: serializeRawSql,
1063
+ provider: options.provider
1003
1064
  });
1004
1065
  }
1005
1066
  async run(queryPlan, queryable) {
@@ -1056,7 +1117,7 @@ var QueryInterpreter = class _QueryInterpreter {
1056
1117
  node.args.map((arg) => this.interpretNode(arg, queryable, scope, generators).then((res) => res.value))
1057
1118
  );
1058
1119
  return {
1059
- value: parts.length > 0 ? parts.reduce((acc, part) => asNumber(acc) + asNumber(part)) : 0
1120
+ value: parts.length > 0 ? parts.reduce((acc, part) => asNumber2(acc) + asNumber2(part)) : 0
1060
1121
  };
1061
1122
  }
1062
1123
  case "execute": {
@@ -1214,8 +1275,8 @@ var QueryInterpreter = class _QueryInterpreter {
1214
1275
  #withQuerySpanAndEvent(query, queryable, execute) {
1215
1276
  return withQuerySpanAndEvent({
1216
1277
  query,
1217
- queryable,
1218
1278
  execute,
1279
+ provider: this.#provider ?? queryable.provider,
1219
1280
  tracingHelper: this.#tracingHelper,
1220
1281
  onQuery: this.#onQuery
1221
1282
  });
@@ -1230,7 +1291,7 @@ function isEmpty(value) {
1230
1291
  function asList(value) {
1231
1292
  return Array.isArray(value) ? value : [value];
1232
1293
  }
1233
- function asNumber(value) {
1294
+ function asNumber2(value) {
1234
1295
  if (typeof value === "number") {
1235
1296
  return value;
1236
1297
  }
@@ -1315,14 +1376,14 @@ function evalFieldOperation(op, value, scope, generators) {
1315
1376
  case "set":
1316
1377
  return evaluateParam(op.value, scope, generators);
1317
1378
  case "add":
1318
- return asNumber(value) + asNumber(evaluateParam(op.value, scope, generators));
1379
+ return asNumber2(value) + asNumber2(evaluateParam(op.value, scope, generators));
1319
1380
  case "subtract":
1320
- return asNumber(value) - asNumber(evaluateParam(op.value, scope, generators));
1381
+ return asNumber2(value) - asNumber2(evaluateParam(op.value, scope, generators));
1321
1382
  case "multiply":
1322
- return asNumber(value) * asNumber(evaluateParam(op.value, scope, generators));
1383
+ return asNumber2(value) * asNumber2(evaluateParam(op.value, scope, generators));
1323
1384
  case "divide": {
1324
- const lhs = asNumber(value);
1325
- const rhs = asNumber(evaluateParam(op.value, scope, generators));
1385
+ const lhs = asNumber2(value);
1386
+ const rhs = asNumber2(evaluateParam(op.value, scope, generators));
1326
1387
  if (rhs === 0) {
1327
1388
  return null;
1328
1389
  }
@@ -1418,16 +1479,19 @@ var TransactionManager = class {
1418
1479
  transactionOptions;
1419
1480
  tracingHelper;
1420
1481
  #onQuery;
1482
+ #provider;
1421
1483
  constructor({
1422
1484
  driverAdapter,
1423
1485
  transactionOptions,
1424
1486
  tracingHelper,
1425
- onQuery
1487
+ onQuery,
1488
+ provider
1426
1489
  }) {
1427
1490
  this.driverAdapter = driverAdapter;
1428
1491
  this.transactionOptions = transactionOptions;
1429
1492
  this.tracingHelper = tracingHelper;
1430
1493
  this.#onQuery = onQuery;
1494
+ this.#provider = provider;
1431
1495
  }
1432
1496
  async startTransaction(options) {
1433
1497
  return await this.tracingHelper.runInChildSpan("start_transaction", () => this.#startTransactionImpl(options));
@@ -1570,8 +1634,8 @@ var TransactionManager = class {
1570
1634
  #withQuerySpanAndEvent(query, queryable, execute) {
1571
1635
  return withQuerySpanAndEvent({
1572
1636
  query,
1573
- queryable,
1574
1637
  execute,
1638
+ provider: this.#provider ?? queryable.provider,
1575
1639
  tracingHelper: this.tracingHelper,
1576
1640
  onQuery: this.#onQuery
1577
1641
  });
package/dist/index.mjs CHANGED
@@ -14,20 +14,74 @@ function doKeysMatch(lhs, rhs) {
14
14
  const rhsKeys = Object.keys(rhs);
15
15
  const smallerKeyList = lhsKeys.length < rhsKeys.length ? lhsKeys : rhsKeys;
16
16
  return smallerKeyList.every((key) => {
17
- if (typeof lhs[key] !== typeof rhs[key]) {
18
- if (typeof lhs[key] === "number" || typeof rhs[key] === "number") {
19
- return `${lhs[key]}` === `${rhs[key]}`;
20
- } else if (typeof lhs[key] === "bigint" || typeof rhs[key] === "bigint") {
21
- return BigInt(`${lhs[key]}`.replace(/n$/, "")) === BigInt(`${rhs[key]}`.replace(/n$/, ""));
22
- } else if (lhs[key] instanceof Date || rhs[key] instanceof Date) {
23
- return (/* @__PURE__ */ new Date(`${lhs[key]}`)).getTime() === (/* @__PURE__ */ new Date(`${rhs[key]}`)).getTime();
24
- } else if (Decimal.isDecimal(lhs[key]) || Decimal.isDecimal(rhs[key])) {
25
- return new Decimal(`${lhs[key]}`).equals(new Decimal(`${rhs[key]}`));
26
- }
17
+ if (typeof lhs[key] === typeof rhs[key] && typeof lhs[key] !== "object") {
18
+ return lhs[key] === rhs[key];
19
+ }
20
+ if (Decimal.isDecimal(lhs[key]) || Decimal.isDecimal(rhs[key])) {
21
+ const lhsDecimal = asDecimal(lhs[key]);
22
+ const rhsDecimal = asDecimal(rhs[key]);
23
+ return lhsDecimal && rhsDecimal && lhsDecimal.equals(rhsDecimal);
24
+ } else if (lhs[key] instanceof Uint8Array || rhs[key] instanceof Uint8Array) {
25
+ const lhsBuffer = asBuffer(lhs[key]);
26
+ const rhsBuffer = asBuffer(rhs[key]);
27
+ return lhsBuffer && rhsBuffer && lhsBuffer.equals(rhsBuffer);
28
+ } else if (lhs[key] instanceof Date || rhs[key] instanceof Date) {
29
+ return asDate(lhs[key])?.getTime() === asDate(rhs[key])?.getTime();
30
+ } else if (typeof lhs[key] === "bigint" || typeof rhs[key] === "bigint") {
31
+ return asBigInt(lhs[key]) === asBigInt(rhs[key]);
32
+ } else if (typeof lhs[key] === "number" || typeof rhs[key] === "number") {
33
+ return asNumber(lhs[key]) === asNumber(rhs[key]);
27
34
  }
28
35
  return isDeepStrictEqual(lhs[key], rhs[key]);
29
36
  });
30
37
  }
38
+ function asDecimal(value) {
39
+ if (Decimal.isDecimal(value)) {
40
+ return value;
41
+ } else if (typeof value === "number" || typeof value === "string") {
42
+ return new Decimal(value);
43
+ } else {
44
+ return;
45
+ }
46
+ }
47
+ function asBuffer(value) {
48
+ if (Buffer.isBuffer(value)) {
49
+ return value;
50
+ } else if (value instanceof Uint8Array) {
51
+ return Buffer.from(value.buffer, value.byteOffset, value.byteLength);
52
+ } else if (typeof value === "string") {
53
+ return Buffer.from(value, "base64");
54
+ } else {
55
+ return;
56
+ }
57
+ }
58
+ function asDate(value) {
59
+ if (value instanceof Date) {
60
+ return value;
61
+ } else if (typeof value === "string" || typeof value === "number") {
62
+ return new Date(value);
63
+ } else {
64
+ return;
65
+ }
66
+ }
67
+ function asBigInt(value) {
68
+ if (typeof value === "bigint") {
69
+ return value;
70
+ } else if (typeof value === "number" || typeof value === "string") {
71
+ return BigInt(value);
72
+ } else {
73
+ return;
74
+ }
75
+ }
76
+ function asNumber(value) {
77
+ if (typeof value === "number") {
78
+ return value;
79
+ } else if (typeof value === "string") {
80
+ return Number(value);
81
+ } else {
82
+ return;
83
+ }
84
+ }
31
85
  function safeJsonStringify(obj) {
32
86
  return JSON.stringify(obj, (_key, val) => {
33
87
  if (typeof val === "bigint") {
@@ -266,22 +320,25 @@ var noopTracingHelper = {
266
320
  };
267
321
  function providerToOtelSystem(provider) {
268
322
  switch (provider) {
323
+ case "postgresql":
269
324
  case "postgres":
325
+ case "prisma+postgres":
270
326
  return "postgresql";
271
- case "mysql":
272
- return "mysql";
273
- case "sqlite":
274
- return "sqlite";
275
327
  case "sqlserver":
276
328
  return "mssql";
329
+ case "mysql":
330
+ case "sqlite":
331
+ case "cockroachdb":
332
+ case "mongodb":
333
+ return provider;
277
334
  default:
278
335
  assertNever(provider, `Unknown provider: ${provider}`);
279
336
  }
280
337
  }
281
338
  async function withQuerySpanAndEvent({
282
339
  query,
283
- queryable,
284
340
  tracingHelper,
341
+ provider,
285
342
  onQuery,
286
343
  execute
287
344
  }) {
@@ -291,7 +348,7 @@ async function withQuerySpanAndEvent({
291
348
  kind: SpanKind.CLIENT,
292
349
  attributes: {
293
350
  "db.query.text": query.sql,
294
- "db.system.name": providerToOtelSystem(queryable.provider)
351
+ "db.system.name": providerToOtelSystem(provider)
295
352
  }
296
353
  },
297
354
  async () => {
@@ -929,13 +986,15 @@ var QueryInterpreter = class _QueryInterpreter {
929
986
  #tracingHelper;
930
987
  #serializer;
931
988
  #rawSerializer;
989
+ #provider;
932
990
  constructor({
933
991
  transactionManager,
934
992
  placeholderValues,
935
993
  onQuery,
936
994
  tracingHelper,
937
995
  serializer,
938
- rawSerializer
996
+ rawSerializer,
997
+ provider
939
998
  }) {
940
999
  this.#transactionManager = transactionManager;
941
1000
  this.#placeholderValues = placeholderValues;
@@ -943,6 +1002,7 @@ var QueryInterpreter = class _QueryInterpreter {
943
1002
  this.#tracingHelper = tracingHelper;
944
1003
  this.#serializer = serializer;
945
1004
  this.#rawSerializer = rawSerializer ?? serializer;
1005
+ this.#provider = provider;
946
1006
  }
947
1007
  static forSql(options) {
948
1008
  return new _QueryInterpreter({
@@ -951,7 +1011,8 @@ var QueryInterpreter = class _QueryInterpreter {
951
1011
  onQuery: options.onQuery,
952
1012
  tracingHelper: options.tracingHelper,
953
1013
  serializer: serializeSql,
954
- rawSerializer: serializeRawSql
1014
+ rawSerializer: serializeRawSql,
1015
+ provider: options.provider
955
1016
  });
956
1017
  }
957
1018
  async run(queryPlan, queryable) {
@@ -1008,7 +1069,7 @@ var QueryInterpreter = class _QueryInterpreter {
1008
1069
  node.args.map((arg) => this.interpretNode(arg, queryable, scope, generators).then((res) => res.value))
1009
1070
  );
1010
1071
  return {
1011
- value: parts.length > 0 ? parts.reduce((acc, part) => asNumber(acc) + asNumber(part)) : 0
1072
+ value: parts.length > 0 ? parts.reduce((acc, part) => asNumber2(acc) + asNumber2(part)) : 0
1012
1073
  };
1013
1074
  }
1014
1075
  case "execute": {
@@ -1166,8 +1227,8 @@ var QueryInterpreter = class _QueryInterpreter {
1166
1227
  #withQuerySpanAndEvent(query, queryable, execute) {
1167
1228
  return withQuerySpanAndEvent({
1168
1229
  query,
1169
- queryable,
1170
1230
  execute,
1231
+ provider: this.#provider ?? queryable.provider,
1171
1232
  tracingHelper: this.#tracingHelper,
1172
1233
  onQuery: this.#onQuery
1173
1234
  });
@@ -1182,7 +1243,7 @@ function isEmpty(value) {
1182
1243
  function asList(value) {
1183
1244
  return Array.isArray(value) ? value : [value];
1184
1245
  }
1185
- function asNumber(value) {
1246
+ function asNumber2(value) {
1186
1247
  if (typeof value === "number") {
1187
1248
  return value;
1188
1249
  }
@@ -1267,14 +1328,14 @@ function evalFieldOperation(op, value, scope, generators) {
1267
1328
  case "set":
1268
1329
  return evaluateParam(op.value, scope, generators);
1269
1330
  case "add":
1270
- return asNumber(value) + asNumber(evaluateParam(op.value, scope, generators));
1331
+ return asNumber2(value) + asNumber2(evaluateParam(op.value, scope, generators));
1271
1332
  case "subtract":
1272
- return asNumber(value) - asNumber(evaluateParam(op.value, scope, generators));
1333
+ return asNumber2(value) - asNumber2(evaluateParam(op.value, scope, generators));
1273
1334
  case "multiply":
1274
- return asNumber(value) * asNumber(evaluateParam(op.value, scope, generators));
1335
+ return asNumber2(value) * asNumber2(evaluateParam(op.value, scope, generators));
1275
1336
  case "divide": {
1276
- const lhs = asNumber(value);
1277
- const rhs = asNumber(evaluateParam(op.value, scope, generators));
1337
+ const lhs = asNumber2(value);
1338
+ const rhs = asNumber2(evaluateParam(op.value, scope, generators));
1278
1339
  if (rhs === 0) {
1279
1340
  return null;
1280
1341
  }
@@ -1370,16 +1431,19 @@ var TransactionManager = class {
1370
1431
  transactionOptions;
1371
1432
  tracingHelper;
1372
1433
  #onQuery;
1434
+ #provider;
1373
1435
  constructor({
1374
1436
  driverAdapter,
1375
1437
  transactionOptions,
1376
1438
  tracingHelper,
1377
- onQuery
1439
+ onQuery,
1440
+ provider
1378
1441
  }) {
1379
1442
  this.driverAdapter = driverAdapter;
1380
1443
  this.transactionOptions = transactionOptions;
1381
1444
  this.tracingHelper = tracingHelper;
1382
1445
  this.#onQuery = onQuery;
1446
+ this.#provider = provider;
1383
1447
  }
1384
1448
  async startTransaction(options) {
1385
1449
  return await this.tracingHelper.runInChildSpan("start_transaction", () => this.#startTransactionImpl(options));
@@ -1522,8 +1586,8 @@ var TransactionManager = class {
1522
1586
  #withQuerySpanAndEvent(query, queryable, execute) {
1523
1587
  return withQuerySpanAndEvent({
1524
1588
  query,
1525
- queryable,
1526
1589
  execute,
1590
+ provider: this.#provider ?? queryable.provider,
1527
1591
  tracingHelper: this.tracingHelper,
1528
1592
  onQuery: this.#onQuery
1529
1593
  });
@@ -1,6 +1,7 @@
1
1
  import { SqlQueryable, SqlResultSet } from '@prisma/driver-adapter-utils';
2
2
  import { QueryEvent } from '../events';
3
3
  import { QueryPlanNode } from '../QueryPlan';
4
+ import { type SchemaProvider } from '../schema';
4
5
  import { type TracingHelper } from '../tracing';
5
6
  import { type TransactionManager } from '../transactionManager/TransactionManager';
6
7
  import { Value } from './scope';
@@ -17,15 +18,17 @@ export type QueryInterpreterOptions = {
17
18
  tracingHelper: TracingHelper;
18
19
  serializer: (results: SqlResultSet) => Value;
19
20
  rawSerializer?: (results: SqlResultSet) => Value;
21
+ provider?: SchemaProvider;
20
22
  };
21
23
  export declare class QueryInterpreter {
22
24
  #private;
23
- constructor({ transactionManager, placeholderValues, onQuery, tracingHelper, serializer, rawSerializer, }: QueryInterpreterOptions);
25
+ constructor({ transactionManager, placeholderValues, onQuery, tracingHelper, serializer, rawSerializer, provider, }: QueryInterpreterOptions);
24
26
  static forSql(options: {
25
27
  transactionManager: QueryInterpreterTransactionManager;
26
28
  placeholderValues: Record<string, unknown>;
27
29
  onQuery?: (event: QueryEvent) => void;
28
30
  tracingHelper: TracingHelper;
31
+ provider?: SchemaProvider;
29
32
  }): QueryInterpreter;
30
33
  run(queryPlan: QueryPlanNode, queryable: SqlQueryable): Promise<unknown>;
31
34
  private interpretNode;
@@ -0,0 +1,4 @@
1
+ /**
2
+ * `provider` property as defined in Prisma Schema (may differ from {@link @prisma/driver-adapter-utils#Provider}).
3
+ */
4
+ export type SchemaProvider = 'cockroachdb' | 'mongodb' | 'mysql' | 'postgres' | 'postgresql' | 'prisma+postgres' | 'sqlite' | 'sqlserver';
package/dist/tracing.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { type Context, type Span, type SpanOptions } from '@opentelemetry/api';
2
- import type { Provider, SqlQuery, SqlQueryable } from '@prisma/driver-adapter-utils';
2
+ import type { SqlQuery } from '@prisma/driver-adapter-utils';
3
3
  import { QueryEvent } from './events';
4
+ import type { SchemaProvider } from './schema';
4
5
  export type SpanCallback<R> = (span?: Span, context?: Context) => R;
5
6
  export type ExtendedSpanOptions = SpanOptions & {
6
7
  name: string;
@@ -9,11 +10,11 @@ export interface TracingHelper {
9
10
  runInChildSpan<R>(nameOrOptions: string | ExtendedSpanOptions, callback: SpanCallback<R>): R;
10
11
  }
11
12
  export declare const noopTracingHelper: TracingHelper;
12
- export declare function providerToOtelSystem(provider: Provider): string;
13
- export declare function withQuerySpanAndEvent<T>({ query, queryable, tracingHelper, onQuery, execute, }: {
13
+ export declare function providerToOtelSystem(provider: SchemaProvider): string;
14
+ export declare function withQuerySpanAndEvent<T>({ query, tracingHelper, provider, onQuery, execute, }: {
14
15
  query: SqlQuery;
15
- queryable: SqlQueryable;
16
16
  tracingHelper: TracingHelper;
17
+ provider: SchemaProvider;
17
18
  onQuery?: (event: QueryEvent) => void;
18
19
  execute: () => Promise<T>;
19
20
  }): Promise<T>;
@@ -1,5 +1,6 @@
1
1
  import { SqlDriverAdapter, Transaction } from '@prisma/driver-adapter-utils';
2
2
  import { QueryEvent } from '../events';
3
+ import type { SchemaProvider } from '../schema';
3
4
  import { TracingHelper } from '../tracing';
4
5
  import { Options, TransactionInfo } from './Transaction';
5
6
  export declare class TransactionManager {
@@ -9,11 +10,12 @@ export declare class TransactionManager {
9
10
  private readonly driverAdapter;
10
11
  private readonly transactionOptions;
11
12
  private readonly tracingHelper;
12
- constructor({ driverAdapter, transactionOptions, tracingHelper, onQuery, }: {
13
+ constructor({ driverAdapter, transactionOptions, tracingHelper, onQuery, provider, }: {
13
14
  driverAdapter: SqlDriverAdapter;
14
15
  transactionOptions: Options;
15
16
  tracingHelper: TracingHelper;
16
17
  onQuery?: (event: QueryEvent) => void;
18
+ provider?: SchemaProvider;
17
19
  });
18
20
  startTransaction(options?: Options): Promise<TransactionInfo>;
19
21
  commitTransaction(transactionId: string): Promise<void>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prisma/client-engine-runtime",
3
- "version": "6.12.0-dev.2",
3
+ "version": "6.12.0-dev.21",
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/driver-adapter-utils": "6.12.0-dev.2",
35
- "@prisma/debug": "6.12.0-dev.2"
34
+ "@prisma/debug": "6.12.0-dev.21",
35
+ "@prisma/driver-adapter-utils": "6.12.0-dev.21"
36
36
  },
37
37
  "devDependencies": {
38
38
  "@types/jest": "29.5.14",