@prisma/query-plan-executor 7.3.0-integration-engines-7-3-0-10-fix-fix-mapped-enum-issue-0b7e6564db7dc3dac7f9312aa84e9ed81d805521.1 → 7.3.0-integration-engines-7-3-0-12-parameterization-844f54891f0a80ec1820fc26cf513002357e4245.1

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.ts CHANGED
@@ -36,12 +36,12 @@ declare class App {
36
36
  * Executes a query plan and returns the result.
37
37
  *
38
38
  * @param queryPlan - The query plan to execute
39
- * @param placeholderValues - Placeholder values for the query
39
+ * @param scope - Placeholder values for the query
40
40
  * @param comments - Pre-computed SQL commenter tags from the client
41
41
  * @param resourceLimits - Resource limits for the query
42
42
  * @param transactionId - Transaction ID if running within a transaction
43
43
  */
44
- query(queryPlan: QueryPlanNode, placeholderValues: Record<string, unknown>, comments: Record<string, string> | undefined, resourceLimits: ResourceLimits, transactionId: string | null): Promise<unknown>;
44
+ query(queryPlan: QueryPlanNode, scope: Record<string, unknown>, comments: Record<string, string> | undefined, resourceLimits: ResourceLimits, transactionId: string | null): Promise<unknown>;
45
45
  /**
46
46
  * Starts a new transaction.
47
47
  */
@@ -3216,10 +3216,12 @@ declare interface TraceState {
3216
3216
  declare class TracingHandler implements TracingHelper {
3217
3217
  #private;
3218
3218
  constructor(tracer: Tracer);
3219
+ isEnabled(): boolean;
3219
3220
  runInChildSpan<R>(nameOrOptions: string | ExtendedSpanOptions_2, callback: (span?: Span, context?: Context) => R): R;
3220
3221
  }
3221
3222
 
3222
3223
  declare interface TracingHelper {
3224
+ isEnabled(): boolean;
3223
3225
  runInChildSpan<R>(nameOrOptions: string | ExtendedSpanOptions, callback: SpanCallback<R>): R;
3224
3226
  }
3225
3227
 
package/dist/index.js CHANGED
@@ -97773,7 +97773,7 @@ __export(index_exports, {
97773
97773
  module.exports = __toCommonJS(index_exports);
97774
97774
 
97775
97775
  // package.json
97776
- var version = "7.3.0-integration-engines-7-3-0-10-fix-fix-mapped-enum-issue-0b7e6564db7dc3dac7f9312aa84e9ed81d805521.1";
97776
+ var version = "7.3.0-integration-engines-7-3-0-12-parameterization-844f54891f0a80ec1820fc26cf513002357e4245.1";
97777
97777
 
97778
97778
  // ../../node_modules/.pnpm/temporal-polyfill@0.3.0/node_modules/temporal-polyfill/chunks/internal.js
97779
97779
  function clampProp(e2, n2, t2, o2, r2) {
@@ -106411,6 +106411,15 @@ var DataMapperError = class extends UserFacingError {
106411
106411
  super(message, "P2023", options);
106412
106412
  }
106413
106413
  };
106414
+ var fieldEntriesCache = /* @__PURE__ */ new WeakMap();
106415
+ function getFieldEntries(fields) {
106416
+ let entries = fieldEntriesCache.get(fields);
106417
+ if (!entries) {
106418
+ entries = Object.entries(fields);
106419
+ fieldEntriesCache.set(fields, entries);
106420
+ }
106421
+ return entries;
106422
+ }
106414
106423
  function applyDataMap(data, structure, enums) {
106415
106424
  switch (structure.type) {
106416
106425
  case "affectedRows":
@@ -106457,19 +106466,20 @@ function mapObject(data, fields, enums) {
106457
106466
  throw new DataMapperError(`Expected an object, but got '${typeof data}'`);
106458
106467
  }
106459
106468
  const result = {};
106460
- for (const [name6, node] of Object.entries(fields)) {
106469
+ for (const [name6, node] of getFieldEntries(fields)) {
106461
106470
  switch (node.type) {
106462
106471
  case "affectedRows": {
106463
106472
  throw new DataMapperError(`Unexpected 'AffectedRows' node in data mapping for field '${name6}'`);
106464
106473
  }
106465
106474
  case "object": {
106466
- if (node.serializedName !== null && !Object.hasOwn(data, node.serializedName)) {
106475
+ const { serializedName, fields: nodeFields, skipNulls } = node;
106476
+ if (serializedName !== null && !Object.hasOwn(data, serializedName)) {
106467
106477
  throw new DataMapperError(
106468
106478
  `Missing data field (Object): '${name6}'; node: ${JSON.stringify(node)}; data: ${JSON.stringify(data)}`
106469
106479
  );
106470
106480
  }
106471
- const target = node.serializedName !== null ? data[node.serializedName] : data;
106472
- result[name6] = mapArrayOrObject(target, node.fields, enums, node.skipNulls);
106481
+ const target = serializedName !== null ? data[serializedName] : data;
106482
+ result[name6] = mapArrayOrObject(target, nodeFields, enums, skipNulls);
106473
106483
  break;
106474
106484
  }
106475
106485
  case "field":
@@ -106713,6 +106723,22 @@ async function withQuerySpanAndEvent({
106713
106723
  onQuery,
106714
106724
  execute
106715
106725
  }) {
106726
+ const callback = onQuery === void 0 ? execute : async () => {
106727
+ const timestamp = /* @__PURE__ */ new Date();
106728
+ const startInstant = performance.now();
106729
+ const result = await execute();
106730
+ const endInstant = performance.now();
106731
+ onQuery({
106732
+ timestamp,
106733
+ duration: endInstant - startInstant,
106734
+ query: query2.sql,
106735
+ params: query2.args
106736
+ });
106737
+ return result;
106738
+ };
106739
+ if (!tracingHelper.isEnabled()) {
106740
+ return callback();
106741
+ }
106716
106742
  return await tracingHelper.runInChildSpan(
106717
106743
  {
106718
106744
  name: "db_query",
@@ -106722,19 +106748,7 @@ async function withQuerySpanAndEvent({
106722
106748
  "db.system.name": providerToOtelSystem(provider)
106723
106749
  }
106724
106750
  },
106725
- async () => {
106726
- const timestamp = /* @__PURE__ */ new Date();
106727
- const startInstant = performance.now();
106728
- const result = await execute();
106729
- const endInstant = performance.now();
106730
- onQuery?.({
106731
- timestamp,
106732
- duration: endInstant - startInstant,
106733
- query: query2.sql,
106734
- params: query2.args
106735
- });
106736
- return result;
106737
- }
106751
+ callback
106738
106752
  );
106739
106753
  }
106740
106754
  var GeneratorRegistry = class {
@@ -107393,8 +107407,6 @@ function getErrorCode2(error44) {
107393
107407
  }
107394
107408
  }
107395
107409
  var QueryInterpreter = class _QueryInterpreter {
107396
- #transactionManager;
107397
- #placeholderValues;
107398
107410
  #onQuery;
107399
107411
  #generators = new GeneratorRegistry();
107400
107412
  #tracingHelper;
@@ -107402,76 +107414,66 @@ var QueryInterpreter = class _QueryInterpreter {
107402
107414
  #rawSerializer;
107403
107415
  #provider;
107404
107416
  #connectionInfo;
107405
- #sqlCommenter;
107406
107417
  constructor({
107407
- transactionManager,
107408
- placeholderValues,
107409
107418
  onQuery,
107410
107419
  tracingHelper,
107411
107420
  serializer,
107412
107421
  rawSerializer,
107413
107422
  provider,
107414
- connectionInfo,
107415
- sqlCommenter
107423
+ connectionInfo
107416
107424
  }) {
107417
- this.#transactionManager = transactionManager;
107418
- this.#placeholderValues = placeholderValues;
107419
107425
  this.#onQuery = onQuery;
107420
107426
  this.#tracingHelper = tracingHelper;
107421
107427
  this.#serializer = serializer;
107422
107428
  this.#rawSerializer = rawSerializer ?? serializer;
107423
107429
  this.#provider = provider;
107424
107430
  this.#connectionInfo = connectionInfo;
107425
- this.#sqlCommenter = sqlCommenter;
107426
107431
  }
107427
107432
  static forSql(options) {
107428
107433
  return new _QueryInterpreter({
107429
- transactionManager: options.transactionManager,
107430
- placeholderValues: options.placeholderValues,
107431
107434
  onQuery: options.onQuery,
107432
107435
  tracingHelper: options.tracingHelper,
107433
107436
  serializer: serializeSql,
107434
107437
  rawSerializer: serializeRawSql,
107435
107438
  provider: options.provider,
107436
- connectionInfo: options.connectionInfo,
107437
- sqlCommenter: options.sqlCommenter
107439
+ connectionInfo: options.connectionInfo
107438
107440
  });
107439
107441
  }
107440
- async run(queryPlan, queryable) {
107441
- const { value } = await this.interpretNode(
107442
- queryPlan,
107443
- queryable,
107444
- this.#placeholderValues,
107445
- this.#generators.snapshot()
107446
- ).catch((e2) => rethrowAsUserFacing(e2));
107442
+ async run(queryPlan, options) {
107443
+ const { value } = await this.interpretNode(queryPlan, {
107444
+ ...options,
107445
+ generators: this.#generators.snapshot()
107446
+ }).catch((e2) => rethrowAsUserFacing(e2));
107447
107447
  return value;
107448
107448
  }
107449
- async interpretNode(node, queryable, scope, generators) {
107449
+ async interpretNode(node, context2) {
107450
107450
  switch (node.type) {
107451
107451
  case "value": {
107452
- return { value: evaluateArg(node.args, scope, generators) };
107452
+ return {
107453
+ value: evaluateArg(node.args, context2.scope, context2.generators)
107454
+ };
107453
107455
  }
107454
107456
  case "seq": {
107455
107457
  let result;
107456
107458
  for (const arg of node.args) {
107457
- result = await this.interpretNode(arg, queryable, scope, generators);
107459
+ result = await this.interpretNode(arg, context2);
107458
107460
  }
107459
107461
  return result ?? { value: void 0 };
107460
107462
  }
107461
107463
  case "get": {
107462
- return { value: scope[node.args.name] };
107464
+ return { value: context2.scope[node.args.name] };
107463
107465
  }
107464
107466
  case "let": {
107465
- const nestedScope = Object.create(scope);
107467
+ const nestedScope = Object.create(context2.scope);
107466
107468
  for (const binding of node.args.bindings) {
107467
- const { value } = await this.interpretNode(binding.expr, queryable, nestedScope, generators);
107469
+ const { value } = await this.interpretNode(binding.expr, { ...context2, scope: nestedScope });
107468
107470
  nestedScope[binding.name] = value;
107469
107471
  }
107470
- return this.interpretNode(node.args.expr, queryable, nestedScope, generators);
107472
+ return this.interpretNode(node.args.expr, { ...context2, scope: nestedScope });
107471
107473
  }
107472
107474
  case "getFirstNonEmpty": {
107473
107475
  for (const name6 of node.args.names) {
107474
- const value = scope[name6];
107476
+ const value = context2.scope[name6];
107475
107477
  if (!isEmpty(value)) {
107476
107478
  return { value };
107477
107479
  }
@@ -107480,7 +107482,7 @@ var QueryInterpreter = class _QueryInterpreter {
107480
107482
  }
107481
107483
  case "concat": {
107482
107484
  const parts = await Promise.all(
107483
- node.args.map((arg) => this.interpretNode(arg, queryable, scope, generators).then((res) => res.value))
107485
+ node.args.map((arg) => this.interpretNode(arg, context2).then((res) => res.value))
107484
107486
  );
107485
107487
  return {
107486
107488
  value: parts.length > 0 ? parts.reduce((acc, part) => acc.concat(asList(part)), []) : []
@@ -107488,21 +107490,21 @@ var QueryInterpreter = class _QueryInterpreter {
107488
107490
  }
107489
107491
  case "sum": {
107490
107492
  const parts = await Promise.all(
107491
- node.args.map((arg) => this.interpretNode(arg, queryable, scope, generators).then((res) => res.value))
107493
+ node.args.map((arg) => this.interpretNode(arg, context2).then((res) => res.value))
107492
107494
  );
107493
107495
  return {
107494
107496
  value: parts.length > 0 ? parts.reduce((acc, part) => asNumber2(acc) + asNumber2(part)) : 0
107495
107497
  };
107496
107498
  }
107497
107499
  case "execute": {
107498
- const queries = renderQuery(node.args, scope, generators, this.#maxChunkSize());
107500
+ const queries = renderQuery(node.args, context2.scope, context2.generators, this.#maxChunkSize());
107499
107501
  let sum2 = 0;
107500
107502
  for (const query2 of queries) {
107501
- const commentedQuery = this.#applyComments(query2);
107503
+ const commentedQuery = applyComments(query2, context2.sqlCommenter);
107502
107504
  sum2 += await this.#withQuerySpanAndEvent(
107503
107505
  commentedQuery,
107504
- queryable,
107505
- () => queryable.executeRaw(commentedQuery).catch(
107506
+ context2.queryable,
107507
+ () => context2.queryable.executeRaw(commentedQuery).catch(
107506
107508
  (err) => node.args.type === "rawSql" ? rethrowAsUserFacingRawError(err) : rethrowAsUserFacing(err)
107507
107509
  )
107508
107510
  );
@@ -107510,14 +107512,14 @@ var QueryInterpreter = class _QueryInterpreter {
107510
107512
  return { value: sum2 };
107511
107513
  }
107512
107514
  case "query": {
107513
- const queries = renderQuery(node.args, scope, generators, this.#maxChunkSize());
107515
+ const queries = renderQuery(node.args, context2.scope, context2.generators, this.#maxChunkSize());
107514
107516
  let results;
107515
107517
  for (const query2 of queries) {
107516
- const commentedQuery = this.#applyComments(query2);
107518
+ const commentedQuery = applyComments(query2, context2.sqlCommenter);
107517
107519
  const result = await this.#withQuerySpanAndEvent(
107518
107520
  commentedQuery,
107519
- queryable,
107520
- () => queryable.queryRaw(commentedQuery).catch(
107521
+ context2.queryable,
107522
+ () => context2.queryable.queryRaw(commentedQuery).catch(
107521
107523
  (err) => node.args.type === "rawSql" ? rethrowAsUserFacingRawError(err) : rethrowAsUserFacing(err)
107522
107524
  )
107523
107525
  );
@@ -107534,11 +107536,11 @@ var QueryInterpreter = class _QueryInterpreter {
107534
107536
  };
107535
107537
  }
107536
107538
  case "reverse": {
107537
- const { value, lastInsertId } = await this.interpretNode(node.args, queryable, scope, generators);
107539
+ const { value, lastInsertId } = await this.interpretNode(node.args, context2);
107538
107540
  return { value: Array.isArray(value) ? value.reverse() : value, lastInsertId };
107539
107541
  }
107540
107542
  case "unique": {
107541
- const { value, lastInsertId } = await this.interpretNode(node.args, queryable, scope, generators);
107543
+ const { value, lastInsertId } = await this.interpretNode(node.args, context2);
107542
107544
  if (!Array.isArray(value)) {
107543
107545
  return { value, lastInsertId };
107544
107546
  }
@@ -107548,38 +107550,38 @@ var QueryInterpreter = class _QueryInterpreter {
107548
107550
  return { value: value[0] ?? null, lastInsertId };
107549
107551
  }
107550
107552
  case "required": {
107551
- const { value, lastInsertId } = await this.interpretNode(node.args, queryable, scope, generators);
107553
+ const { value, lastInsertId } = await this.interpretNode(node.args, context2);
107552
107554
  if (isEmpty(value)) {
107553
107555
  throw new Error("Required value is empty");
107554
107556
  }
107555
107557
  return { value, lastInsertId };
107556
107558
  }
107557
107559
  case "mapField": {
107558
- const { value, lastInsertId } = await this.interpretNode(node.args.records, queryable, scope, generators);
107560
+ const { value, lastInsertId } = await this.interpretNode(node.args.records, context2);
107559
107561
  return { value: mapField2(value, node.args.field), lastInsertId };
107560
107562
  }
107561
107563
  case "join": {
107562
- const { value: parent, lastInsertId } = await this.interpretNode(node.args.parent, queryable, scope, generators);
107564
+ const { value: parent, lastInsertId } = await this.interpretNode(node.args.parent, context2);
107563
107565
  if (parent === null) {
107564
107566
  return { value: null, lastInsertId };
107565
107567
  }
107566
107568
  const children = await Promise.all(
107567
107569
  node.args.children.map(async (joinExpr) => ({
107568
107570
  joinExpr,
107569
- childRecords: (await this.interpretNode(joinExpr.child, queryable, scope, generators)).value
107571
+ childRecords: (await this.interpretNode(joinExpr.child, context2)).value
107570
107572
  }))
107571
107573
  );
107572
107574
  return { value: attachChildrenToParents(parent, children), lastInsertId };
107573
107575
  }
107574
107576
  case "transaction": {
107575
- if (!this.#transactionManager.enabled) {
107576
- return this.interpretNode(node.args, queryable, scope, generators);
107577
+ if (!context2.transactionManager.enabled) {
107578
+ return this.interpretNode(node.args, context2);
107577
107579
  }
107578
- const transactionManager = this.#transactionManager.manager;
107580
+ const transactionManager = context2.transactionManager.manager;
107579
107581
  const transactionInfo = await transactionManager.startInternalTransaction();
107580
107582
  const transaction = await transactionManager.getTransaction(transactionInfo, "query");
107581
107583
  try {
107582
- const value = await this.interpretNode(node.args, transaction, scope, generators);
107584
+ const value = await this.interpretNode(node.args, { ...context2, queryable: transaction });
107583
107585
  await transactionManager.commitTransaction(transactionInfo.id);
107584
107586
  return value;
107585
107587
  } catch (e2) {
@@ -107588,49 +107590,49 @@ var QueryInterpreter = class _QueryInterpreter {
107588
107590
  }
107589
107591
  }
107590
107592
  case "dataMap": {
107591
- const { value, lastInsertId } = await this.interpretNode(node.args.expr, queryable, scope, generators);
107593
+ const { value, lastInsertId } = await this.interpretNode(node.args.expr, context2);
107592
107594
  return { value: applyDataMap(value, node.args.structure, node.args.enums), lastInsertId };
107593
107595
  }
107594
107596
  case "validate": {
107595
- const { value, lastInsertId } = await this.interpretNode(node.args.expr, queryable, scope, generators);
107597
+ const { value, lastInsertId } = await this.interpretNode(node.args.expr, context2);
107596
107598
  performValidation(value, node.args.rules, node.args);
107597
107599
  return { value, lastInsertId };
107598
107600
  }
107599
107601
  case "if": {
107600
- const { value } = await this.interpretNode(node.args.value, queryable, scope, generators);
107602
+ const { value } = await this.interpretNode(node.args.value, context2);
107601
107603
  if (doesSatisfyRule(value, node.args.rule)) {
107602
- return await this.interpretNode(node.args.then, queryable, scope, generators);
107604
+ return await this.interpretNode(node.args.then, context2);
107603
107605
  } else {
107604
- return await this.interpretNode(node.args.else, queryable, scope, generators);
107606
+ return await this.interpretNode(node.args.else, context2);
107605
107607
  }
107606
107608
  }
107607
107609
  case "unit": {
107608
107610
  return { value: void 0 };
107609
107611
  }
107610
107612
  case "diff": {
107611
- const { value: from } = await this.interpretNode(node.args.from, queryable, scope, generators);
107612
- const { value: to2 } = await this.interpretNode(node.args.to, queryable, scope, generators);
107613
+ const { value: from } = await this.interpretNode(node.args.from, context2);
107614
+ const { value: to2 } = await this.interpretNode(node.args.to, context2);
107613
107615
  const keyGetter = (item) => item !== null ? getRecordKey(asRecord(item), node.args.fields) : null;
107614
107616
  const toSet = new Set(asList(to2).map(keyGetter));
107615
107617
  return { value: asList(from).filter((item) => !toSet.has(keyGetter(item))) };
107616
107618
  }
107617
107619
  case "process": {
107618
- const { value, lastInsertId } = await this.interpretNode(node.args.expr, queryable, scope, generators);
107620
+ const { value, lastInsertId } = await this.interpretNode(node.args.expr, context2);
107619
107621
  return { value: processRecords(value, node.args.operations), lastInsertId };
107620
107622
  }
107621
107623
  case "initializeRecord": {
107622
- const { lastInsertId } = await this.interpretNode(node.args.expr, queryable, scope, generators);
107624
+ const { lastInsertId } = await this.interpretNode(node.args.expr, context2);
107623
107625
  const record2 = {};
107624
107626
  for (const [key, initializer3] of Object.entries(node.args.fields)) {
107625
- record2[key] = evalFieldInitializer(initializer3, lastInsertId, scope, generators);
107627
+ record2[key] = evalFieldInitializer(initializer3, lastInsertId, context2.scope, context2.generators);
107626
107628
  }
107627
107629
  return { value: record2, lastInsertId };
107628
107630
  }
107629
107631
  case "mapRecord": {
107630
- const { value, lastInsertId } = await this.interpretNode(node.args.expr, queryable, scope, generators);
107632
+ const { value, lastInsertId } = await this.interpretNode(node.args.expr, context2);
107631
107633
  const record2 = value === null ? {} : asRecord(value);
107632
107634
  for (const [key, entry] of Object.entries(node.args.fields)) {
107633
- record2[key] = evalFieldOperation(entry, record2[key], scope, generators);
107635
+ record2[key] = evalFieldOperation(entry, record2[key], context2.scope, context2.generators);
107634
107636
  }
107635
107637
  return { value: record2, lastInsertId };
107636
107638
  }
@@ -107675,22 +107677,6 @@ var QueryInterpreter = class _QueryInterpreter {
107675
107677
  onQuery: this.#onQuery
107676
107678
  });
107677
107679
  }
107678
- #applyComments(query2) {
107679
- if (!this.#sqlCommenter || this.#sqlCommenter.plugins.length === 0) {
107680
- return query2;
107681
- }
107682
- const comment = buildSqlComment(this.#sqlCommenter.plugins, {
107683
- query: this.#sqlCommenter.queryInfo,
107684
- sql: query2.sql
107685
- });
107686
- if (!comment) {
107687
- return query2;
107688
- }
107689
- return {
107690
- ...query2,
107691
- sql: appendSqlComment(query2.sql, comment)
107692
- };
107693
- }
107694
107680
  };
107695
107681
  function isEmpty(value) {
107696
107682
  if (Array.isArray(value)) {
@@ -107791,6 +107777,22 @@ function evalFieldOperation(op, value, scope, generators) {
107791
107777
  assertNever(op, `Unexpected field operation type: ${op["type"]}`);
107792
107778
  }
107793
107779
  }
107780
+ function applyComments(query2, sqlCommenter) {
107781
+ if (!sqlCommenter || sqlCommenter.plugins.length === 0) {
107782
+ return query2;
107783
+ }
107784
+ const comment = buildSqlComment(sqlCommenter.plugins, {
107785
+ query: sqlCommenter.queryInfo,
107786
+ sql: query2.sql
107787
+ });
107788
+ if (!comment) {
107789
+ return query2;
107790
+ }
107791
+ return {
107792
+ ...query2,
107793
+ sql: appendSqlComment(query2.sql, comment)
107794
+ };
107795
+ }
107794
107796
  async function getCrypto() {
107795
107797
  return globalThis.crypto ?? await import("node:crypto");
107796
107798
  }
@@ -109603,6 +109605,9 @@ var TracingHandler = class {
109603
109605
  constructor(tracer2) {
109604
109606
  this.#tracer = tracer2;
109605
109607
  }
109608
+ isEnabled() {
109609
+ return true;
109610
+ }
109606
109611
  runInChildSpan(nameOrOptions, callback) {
109607
109612
  const options = normalizeSpanOptions(nameOrOptions);
109608
109613
  return new SpanScope(options, this.#tracer).run(callback);
@@ -110083,7 +110088,17 @@ var PrismaMariaDbAdapterFactory = class {
110083
110088
  this.#options = options;
110084
110089
  }
110085
110090
  async connect() {
110086
- const pool2 = mariadb.createPool(this.#config);
110091
+ let pool2;
110092
+ try {
110093
+ pool2 = mariadb.createPool(this.#config);
110094
+ } catch (error44) {
110095
+ if (error44 instanceof Error && error44.message.startsWith("error parsing connection string")) {
110096
+ throw new Error(
110097
+ "error parsing connection string, format must be 'mariadb://[<user>[:<password>]@]<host>[:<port>]/[<db>[?<opt1>=<value1>[&<opt2>=<value2>]]]'"
110098
+ );
110099
+ }
110100
+ throw error44;
110101
+ }
110087
110102
  if (this.#capabilities === void 0) {
110088
110103
  this.#capabilities = await getCapabilities(pool2);
110089
110104
  }
@@ -111833,10 +111848,11 @@ var PrismaPgAdapterFactory = class {
111833
111848
  };
111834
111849
 
111835
111850
  // src/logic/adapter.ts
111836
- function createAdapter(url2) {
111837
- for (const factory of factories) {
111851
+ function createAdapter(url2, supportedFactories = defaultFactories) {
111852
+ const allSupportedProtocols = supportedFactories.flatMap((factory) => factory.protocols);
111853
+ for (const factory of supportedFactories) {
111838
111854
  if (factory.protocols.some((protocol) => url2.startsWith(`${protocol}://`))) {
111839
- return factory.create(url2);
111855
+ return wrapFactory(allSupportedProtocols, factory.create(url2));
111840
111856
  }
111841
111857
  }
111842
111858
  let urlObj;
@@ -111847,7 +111863,7 @@ function createAdapter(url2) {
111847
111863
  }
111848
111864
  throw new Error(`Unsupported protocol in database URL: ${urlObj.protocol}`);
111849
111865
  }
111850
- var factories = [
111866
+ var defaultFactories = [
111851
111867
  {
111852
111868
  protocols: ["postgres", "postgresql"],
111853
111869
  create(connectionString) {
@@ -111877,6 +111893,71 @@ var factories = [
111877
111893
  }
111878
111894
  }
111879
111895
  ];
111896
+ function rethrowSanitizedError(protocols, error44) {
111897
+ if (typeof error44 === "object" && error44 !== null) {
111898
+ sanitizeError(error44, createConnectionStringRegex(protocols));
111899
+ }
111900
+ throw error44;
111901
+ }
111902
+ function sanitizeError(error44, regex, visited = /* @__PURE__ */ new WeakSet()) {
111903
+ if (visited.has(error44)) {
111904
+ return;
111905
+ }
111906
+ visited.add(error44);
111907
+ for (const key of Object.getOwnPropertyNames(error44)) {
111908
+ const value = error44[key];
111909
+ if (typeof value === "string") {
111910
+ try {
111911
+ error44[key] = value.replaceAll(regex, "[REDACTED]");
111912
+ } catch {
111913
+ }
111914
+ } else if (typeof value === "object" && value !== null) {
111915
+ sanitizeError(value, regex, visited);
111916
+ }
111917
+ }
111918
+ }
111919
+ function createConnectionStringRegex(protocols) {
111920
+ const escapedProtocols = protocols.join("|");
111921
+ const pattern = [
111922
+ `['"\`]?`,
111923
+ // Optional opening quote
111924
+ `(${escapedProtocols})`,
111925
+ // Protocol group
111926
+ `:\\/\\/`,
111927
+ // Protocol separator
111928
+ `[^\\s]+`,
111929
+ // Connection string body
111930
+ `['"\`]?`
111931
+ // Optional closing quote
111932
+ ].join("");
111933
+ return new RegExp(pattern, "gi");
111934
+ }
111935
+ function wrapFactory(protocols, factory) {
111936
+ return {
111937
+ ...factory,
111938
+ connect: () => factory.connect().then(wrapAdapter.bind(null, protocols), rethrowSanitizedError.bind(null, protocols))
111939
+ };
111940
+ }
111941
+ function wrapAdapter(protocols, adapter) {
111942
+ return {
111943
+ ...adapter,
111944
+ dispose: () => adapter.dispose().catch(rethrowSanitizedError.bind(null, protocols)),
111945
+ executeRaw: (query2) => adapter.executeRaw(query2).catch(rethrowSanitizedError.bind(null, protocols)),
111946
+ queryRaw: (query2) => adapter.queryRaw(query2).catch(rethrowSanitizedError.bind(null, protocols)),
111947
+ executeScript: (script) => adapter.executeScript(script).catch(rethrowSanitizedError.bind(null, protocols)),
111948
+ startTransaction: (isolationLevel) => adapter.startTransaction(isolationLevel).then(wrapTransaction.bind(null, protocols), rethrowSanitizedError.bind(null, protocols)),
111949
+ getConnectionInfo: adapter.getConnectionInfo?.bind(adapter)
111950
+ };
111951
+ }
111952
+ function wrapTransaction(protocols, tx) {
111953
+ return {
111954
+ ...tx,
111955
+ commit: () => tx.commit().catch(rethrowSanitizedError.bind(null, protocols)),
111956
+ rollback: () => tx.rollback().catch(rethrowSanitizedError.bind(null, protocols)),
111957
+ executeRaw: (query2) => tx.executeRaw(query2).catch(rethrowSanitizedError.bind(null, protocols)),
111958
+ queryRaw: (query2) => tx.queryRaw(query2).catch(rethrowSanitizedError.bind(null, protocols))
111959
+ };
111960
+ }
111880
111961
 
111881
111962
  // src/logic/resource-limits.ts
111882
111963
  var ResourceLimitError = class extends Error {
@@ -111891,10 +111972,15 @@ var App = class _App {
111891
111972
  #db;
111892
111973
  #transactionManager;
111893
111974
  #tracingHandler;
111975
+ #interpreter;
111894
111976
  constructor(db, transactionManager, tracingHandler) {
111895
111977
  this.#db = db;
111896
111978
  this.#transactionManager = transactionManager;
111897
111979
  this.#tracingHandler = tracingHandler;
111980
+ this.#interpreter = QueryInterpreter.forSql({
111981
+ tracingHelper: this.#tracingHandler,
111982
+ onQuery: logQuery
111983
+ });
111898
111984
  }
111899
111985
  /**
111900
111986
  * Connects to the database and initializes the application logic.
@@ -111928,12 +112014,12 @@ var App = class _App {
111928
112014
  * Executes a query plan and returns the result.
111929
112015
  *
111930
112016
  * @param queryPlan - The query plan to execute
111931
- * @param placeholderValues - Placeholder values for the query
112017
+ * @param scope - Placeholder values for the query
111932
112018
  * @param comments - Pre-computed SQL commenter tags from the client
111933
112019
  * @param resourceLimits - Resource limits for the query
111934
112020
  * @param transactionId - Transaction ID if running within a transaction
111935
112021
  */
111936
- async query(queryPlan, placeholderValues, comments, resourceLimits, transactionId) {
112022
+ async query(queryPlan, scope, comments, resourceLimits, transactionId) {
111937
112023
  const queryable = transactionId !== null ? await this.#transactionManager.getTransaction({ id: transactionId }, "query") : this.#db;
111938
112024
  const sqlCommenter = comments && Object.keys(comments).length > 0 ? {
111939
112025
  plugins: [() => comments],
@@ -111941,15 +112027,13 @@ var App = class _App {
111941
112027
  // query info was already used on the client side to compute the comments
111942
112028
  queryInfo: { type: "single", action: "queryRaw", query: {} }
111943
112029
  } : void 0;
111944
- const queryInterpreter = QueryInterpreter.forSql({
111945
- placeholderValues,
111946
- tracingHelper: this.#tracingHandler,
111947
- transactionManager: transactionId === null ? { enabled: true, manager: this.#transactionManager } : { enabled: false },
111948
- onQuery: logQuery,
111949
- sqlCommenter
111950
- });
111951
112030
  const result = await Promise.race([
111952
- queryInterpreter.run(queryPlan, queryable),
112031
+ this.#interpreter.run(queryPlan, {
112032
+ queryable,
112033
+ transactionManager: transactionId === null ? { enabled: true, manager: this.#transactionManager } : { enabled: false },
112034
+ scope,
112035
+ sqlCommenter
112036
+ }),
111953
112037
  import_promises3.default.setTimeout(resourceLimits.queryTimeout.total("milliseconds"), void 0, { ref: false }).then(() => {
111954
112038
  throw new ResourceLimitError("Query timeout exceeded");
111955
112039
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prisma/query-plan-executor",
3
- "version": "7.3.0-integration-engines-7-3-0-10-fix-fix-mapped-enum-issue-0b7e6564db7dc3dac7f9312aa84e9ed81d805521.1",
3
+ "version": "7.3.0-integration-engines-7-3-0-12-parameterization-844f54891f0a80ec1820fc26cf513002357e4245.1",
4
4
  "description": "This package is intended for Prisma's internal use",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -20,11 +20,11 @@
20
20
  "temporal-polyfill": "0.3.0",
21
21
  "vitest": "3.2.4",
22
22
  "zod": "4.1.3",
23
- "@prisma/adapter-pg": "7.3.0-integration-engines-7-3-0-10-fix-fix-mapped-enum-issue-0b7e6564db7dc3dac7f9312aa84e9ed81d805521.1",
24
- "@prisma/adapter-mariadb": "7.3.0-integration-engines-7-3-0-10-fix-fix-mapped-enum-issue-0b7e6564db7dc3dac7f9312aa84e9ed81d805521.1",
25
- "@prisma/client-engine-runtime": "7.3.0-integration-engines-7-3-0-10-fix-fix-mapped-enum-issue-0b7e6564db7dc3dac7f9312aa84e9ed81d805521.1",
26
- "@prisma/adapter-mssql": "7.3.0-integration-engines-7-3-0-10-fix-fix-mapped-enum-issue-0b7e6564db7dc3dac7f9312aa84e9ed81d805521.1",
27
- "@prisma/driver-adapter-utils": "7.3.0-integration-engines-7-3-0-10-fix-fix-mapped-enum-issue-0b7e6564db7dc3dac7f9312aa84e9ed81d805521.1"
23
+ "@prisma/adapter-pg": "7.3.0-integration-engines-7-3-0-12-parameterization-844f54891f0a80ec1820fc26cf513002357e4245.1",
24
+ "@prisma/adapter-mariadb": "7.3.0-integration-engines-7-3-0-12-parameterization-844f54891f0a80ec1820fc26cf513002357e4245.1",
25
+ "@prisma/client-engine-runtime": "7.3.0-integration-engines-7-3-0-12-parameterization-844f54891f0a80ec1820fc26cf513002357e4245.1",
26
+ "@prisma/driver-adapter-utils": "7.3.0-integration-engines-7-3-0-12-parameterization-844f54891f0a80ec1820fc26cf513002357e4245.1",
27
+ "@prisma/adapter-mssql": "7.3.0-integration-engines-7-3-0-12-parameterization-844f54891f0a80ec1820fc26cf513002357e4245.1"
28
28
  },
29
29
  "files": [
30
30
  "dist"