@prisma/query-plan-executor 7.2.0 → 7.3.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.
package/dist/index.d.ts CHANGED
@@ -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.2.0";
97776
+ var version = "7.3.0-dev.10";
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) {
@@ -105707,6 +105707,76 @@ var mockAdapterErrors = {
105707
105707
  dispose: new Error("Not implemented: dispose")
105708
105708
  };
105709
105709
 
105710
+ // ../../node_modules/.pnpm/klona@2.0.6/node_modules/klona/dist/index.mjs
105711
+ function klona(x2) {
105712
+ if (typeof x2 !== "object") return x2;
105713
+ var k2, tmp, str = Object.prototype.toString.call(x2);
105714
+ if (str === "[object Object]") {
105715
+ if (x2.constructor !== Object && typeof x2.constructor === "function") {
105716
+ tmp = new x2.constructor();
105717
+ for (k2 in x2) {
105718
+ if (x2.hasOwnProperty(k2) && tmp[k2] !== x2[k2]) {
105719
+ tmp[k2] = klona(x2[k2]);
105720
+ }
105721
+ }
105722
+ } else {
105723
+ tmp = {};
105724
+ for (k2 in x2) {
105725
+ if (k2 === "__proto__") {
105726
+ Object.defineProperty(tmp, k2, {
105727
+ value: klona(x2[k2]),
105728
+ configurable: true,
105729
+ enumerable: true,
105730
+ writable: true
105731
+ });
105732
+ } else {
105733
+ tmp[k2] = klona(x2[k2]);
105734
+ }
105735
+ }
105736
+ }
105737
+ return tmp;
105738
+ }
105739
+ if (str === "[object Array]") {
105740
+ k2 = x2.length;
105741
+ for (tmp = Array(k2); k2--; ) {
105742
+ tmp[k2] = klona(x2[k2]);
105743
+ }
105744
+ return tmp;
105745
+ }
105746
+ if (str === "[object Set]") {
105747
+ tmp = /* @__PURE__ */ new Set();
105748
+ x2.forEach(function(val) {
105749
+ tmp.add(klona(val));
105750
+ });
105751
+ return tmp;
105752
+ }
105753
+ if (str === "[object Map]") {
105754
+ tmp = /* @__PURE__ */ new Map();
105755
+ x2.forEach(function(val, key) {
105756
+ tmp.set(klona(key), klona(val));
105757
+ });
105758
+ return tmp;
105759
+ }
105760
+ if (str === "[object Date]") {
105761
+ return /* @__PURE__ */ new Date(+x2);
105762
+ }
105763
+ if (str === "[object RegExp]") {
105764
+ tmp = new RegExp(x2.source, x2.flags);
105765
+ tmp.lastIndex = x2.lastIndex;
105766
+ return tmp;
105767
+ }
105768
+ if (str === "[object DataView]") {
105769
+ return new x2.constructor(klona(x2.buffer));
105770
+ }
105771
+ if (str === "[object ArrayBuffer]") {
105772
+ return x2.slice(0);
105773
+ }
105774
+ if (str.slice(-6) === "Array]") {
105775
+ return new x2.constructor(x2);
105776
+ }
105777
+ return x2;
105778
+ }
105779
+
105710
105780
  // ../../node_modules/.pnpm/@bugsnag+cuid@3.2.1/node_modules/@bugsnag/cuid/lib/pad.mjs
105711
105781
  function pad(num, size) {
105712
105782
  var s2 = "000000000" + num;
@@ -106341,6 +106411,15 @@ var DataMapperError = class extends UserFacingError {
106341
106411
  super(message, "P2023", options);
106342
106412
  }
106343
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
+ }
106344
106423
  function applyDataMap(data, structure, enums) {
106345
106424
  switch (structure.type) {
106346
106425
  case "affectedRows":
@@ -106387,19 +106466,20 @@ function mapObject(data, fields, enums) {
106387
106466
  throw new DataMapperError(`Expected an object, but got '${typeof data}'`);
106388
106467
  }
106389
106468
  const result = {};
106390
- for (const [name6, node] of Object.entries(fields)) {
106469
+ for (const [name6, node] of getFieldEntries(fields)) {
106391
106470
  switch (node.type) {
106392
106471
  case "affectedRows": {
106393
106472
  throw new DataMapperError(`Unexpected 'AffectedRows' node in data mapping for field '${name6}'`);
106394
106473
  }
106395
106474
  case "object": {
106396
- if (node.serializedName !== null && !Object.hasOwn(data, node.serializedName)) {
106475
+ const { serializedName, fields: nodeFields, skipNulls } = node;
106476
+ if (serializedName !== null && !Object.hasOwn(data, serializedName)) {
106397
106477
  throw new DataMapperError(
106398
106478
  `Missing data field (Object): '${name6}'; node: ${JSON.stringify(node)}; data: ${JSON.stringify(data)}`
106399
106479
  );
106400
106480
  }
106401
- const target = node.serializedName !== null ? data[node.serializedName] : data;
106402
- 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);
106403
106483
  break;
106404
106484
  }
106405
106485
  case "field":
@@ -106600,7 +106680,7 @@ function formatSqlComment(tags) {
106600
106680
  function applySqlCommenters(plugins, context2) {
106601
106681
  const merged = {};
106602
106682
  for (const plugin of plugins) {
106603
- const tags = plugin(context2);
106683
+ const tags = plugin(klona(context2));
106604
106684
  for (const [key, value] of Object.entries(tags)) {
106605
106685
  if (value !== void 0) {
106606
106686
  merged[key] = value;
@@ -106643,6 +106723,22 @@ async function withQuerySpanAndEvent({
106643
106723
  onQuery,
106644
106724
  execute
106645
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
+ }
106646
106742
  return await tracingHelper.runInChildSpan(
106647
106743
  {
106648
106744
  name: "db_query",
@@ -106652,19 +106748,7 @@ async function withQuerySpanAndEvent({
106652
106748
  "db.system.name": providerToOtelSystem(provider)
106653
106749
  }
106654
106750
  },
106655
- async () => {
106656
- const timestamp = /* @__PURE__ */ new Date();
106657
- const startInstant = performance.now();
106658
- const result = await execute();
106659
- const endInstant = performance.now();
106660
- onQuery?.({
106661
- timestamp,
106662
- duration: endInstant - startInstant,
106663
- query: query2.sql,
106664
- params: query2.args
106665
- });
106666
- return result;
106667
- }
106751
+ callback
106668
106752
  );
106669
106753
  }
106670
106754
  var GeneratorRegistry = class {
@@ -109533,6 +109617,9 @@ var TracingHandler = class {
109533
109617
  constructor(tracer2) {
109534
109618
  this.#tracer = tracer2;
109535
109619
  }
109620
+ isEnabled() {
109621
+ return true;
109622
+ }
109536
109623
  runInChildSpan(nameOrOptions, callback) {
109537
109624
  const options = normalizeSpanOptions(nameOrOptions);
109538
109625
  return new SpanScope(options, this.#tracer).run(callback);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prisma/query-plan-executor",
3
- "version": "7.2.0",
3
+ "version": "7.3.0-dev.10",
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.2.0",
24
- "@prisma/adapter-mariadb": "7.2.0",
25
- "@prisma/adapter-mssql": "7.2.0",
26
- "@prisma/client-engine-runtime": "7.2.0",
27
- "@prisma/driver-adapter-utils": "7.2.0"
23
+ "@prisma/adapter-mariadb": "7.3.0-dev.10",
24
+ "@prisma/adapter-pg": "7.3.0-dev.10",
25
+ "@prisma/adapter-mssql": "7.3.0-dev.10",
26
+ "@prisma/driver-adapter-utils": "7.3.0-dev.10",
27
+ "@prisma/client-engine-runtime": "7.3.0-dev.10"
28
28
  },
29
29
  "files": [
30
30
  "dist"