@prisma/query-plan-executor 7.10.0-dev.4 → 7.10.0-dev.5

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 (2) hide show
  1. package/dist/index.js +59 -32
  2. package/package.json +6 -6
package/dist/index.js CHANGED
@@ -22009,7 +22009,7 @@ var require_promise = __commonJS({
22009
22009
  return Promise.reject(err);
22010
22010
  }
22011
22011
  };
22012
- module2.exports.createPool = function createPool2(opts) {
22012
+ module2.exports.createPool = function createPool3(opts) {
22013
22013
  const options = new PoolOptions(opts);
22014
22014
  const pool2 = new PoolPromise(options);
22015
22015
  pool2.on("error", (err) => {
@@ -93473,7 +93473,7 @@ __export(index_exports, {
93473
93473
  module.exports = __toCommonJS(index_exports);
93474
93474
 
93475
93475
  // package.json
93476
- var version = "7.10.0-dev.4";
93476
+ var version = "7.10.0-dev.5";
93477
93477
 
93478
93478
  // ../../node_modules/.pnpm/temporal-polyfill@0.3.0/node_modules/temporal-polyfill/chunks/internal.js
93479
93479
  function clampProp(e2, n2, t2, o2, r2) {
@@ -106490,10 +106490,11 @@ var MariaDbTransaction = class extends MariaDbQueryable {
106490
106490
  }
106491
106491
  };
106492
106492
  var PrismaMariaDbAdapter = class extends MariaDbQueryable {
106493
- constructor(client, capabilities, mariadbOptions) {
106493
+ constructor(client, capabilities, mariadbOptions, release) {
106494
106494
  super(client, mariadbOptions);
106495
106495
  this.capabilities = capabilities;
106496
106496
  this.mariadbOptions = mariadbOptions;
106497
+ this.release = release;
106497
106498
  }
106498
106499
  executeScript(_script) {
106499
106500
  throw new Error("Not implemented yet");
@@ -106537,7 +106538,7 @@ var PrismaMariaDbAdapter = class extends MariaDbQueryable {
106537
106538
  }
106538
106539
  }
106539
106540
  async dispose() {
106540
- await this.client.end();
106541
+ return this.release?.();
106541
106542
  }
106542
106543
  underlyingDriver() {
106543
106544
  return this.client;
@@ -106547,47 +106548,73 @@ var PrismaMariaDbAdapterFactory = class {
106547
106548
  provider = "mysql";
106548
106549
  adapterName = name;
106549
106550
  #capabilities;
106550
- #config;
106551
+ #poolOrConfig;
106551
106552
  #options;
106552
- constructor(config3, options) {
106553
- if (typeof config3 === "string") {
106554
- try {
106555
- const url2 = new URL(config3);
106556
- if (!url2.searchParams.has("prepareCacheLength")) {
106557
- url2.searchParams.set("prepareCacheLength", "0");
106558
- }
106559
- this.#config = rewriteConnectionString(url2).toString();
106560
- } catch (error44) {
106561
- debug4("Error parsing connection string: %O", error44);
106562
- this.#config = config3;
106563
- }
106564
- } else {
106565
- if (config3.prepareCacheLength === void 0) {
106566
- this.#config = { ...config3, prepareCacheLength: 0 };
106567
- } else {
106568
- this.#config = config3;
106569
- }
106570
- }
106553
+ #externalPoolClaimed = false;
106554
+ /**
106555
+ * Accepts either connection settings for a pool the adapter creates and owns, or an existing
106556
+ * pool. Settings the adapter would normally apply to its own pool (such as defaulting
106557
+ * `prepareCacheLength` to 0) are not applied to an externally created pool.
106558
+ */
106559
+ constructor(poolOrConfig, options) {
106560
+ this.#poolOrConfig = isPool(poolOrConfig) ? { type: "pool", pool: poolOrConfig } : { type: "config", config: normalizeConfig(poolOrConfig) };
106571
106561
  this.#options = options;
106572
106562
  }
106573
106563
  async connect() {
106574
- let pool2;
106575
- try {
106576
- pool2 = mariadb.createPool(this.#config);
106577
- } catch (error44) {
106578
- if (error44 instanceof Error && error44.message.startsWith("error parsing connection string")) {
106564
+ const poolOrConfig = this.#poolOrConfig;
106565
+ const ownsPool = poolOrConfig.type === "config" || this.#options?.disposeExternalPool === true;
106566
+ if (poolOrConfig.type === "pool" && ownsPool) {
106567
+ if (this.#externalPoolClaimed) {
106579
106568
  throw new Error(
106580
- "error parsing connection string, format must be 'mariadb://[<user>[:<password>]@]<host>[:<port>]/[<db>[?<opt1>=<value1>[&<opt2>=<value2>]]]'"
106569
+ "connect() can only be called once when `disposeExternalPool` is true, because the adapter ends the pool it was given and cannot create a replacement from it. Either pass connection settings instead of a pool, or set `disposeExternalPool: false` and end the pool yourself once you no longer need the adapter."
106581
106570
  );
106582
106571
  }
106583
- throw error44;
106572
+ this.#externalPoolClaimed = true;
106584
106573
  }
106574
+ const pool2 = poolOrConfig.type === "pool" ? poolOrConfig.pool : createPool2(poolOrConfig.config);
106585
106575
  if (this.#capabilities === void 0) {
106586
106576
  this.#capabilities = await getCapabilities(pool2);
106587
106577
  }
106588
- return new PrismaMariaDbAdapter(pool2, this.#capabilities, this.#options);
106578
+ return new PrismaMariaDbAdapter(pool2, this.#capabilities, this.#options, async () => {
106579
+ if (ownsPool) {
106580
+ await pool2.end();
106581
+ }
106582
+ });
106589
106583
  }
106590
106584
  };
106585
+ function isPool(poolOrConfig) {
106586
+ return typeof poolOrConfig === "object" && typeof poolOrConfig.getConnection === "function";
106587
+ }
106588
+ function normalizeConfig(config3) {
106589
+ if (typeof config3 === "string") {
106590
+ try {
106591
+ const url2 = new URL(config3);
106592
+ if (!url2.searchParams.has("prepareCacheLength")) {
106593
+ url2.searchParams.set("prepareCacheLength", "0");
106594
+ }
106595
+ return rewriteConnectionString(url2).toString();
106596
+ } catch {
106597
+ debug4("Failed to parse the connection string, passing it to the driver as-is");
106598
+ return config3;
106599
+ }
106600
+ }
106601
+ if (config3.prepareCacheLength === void 0) {
106602
+ return { ...config3, prepareCacheLength: 0 };
106603
+ }
106604
+ return config3;
106605
+ }
106606
+ function createPool2(config3) {
106607
+ try {
106608
+ return mariadb.createPool(config3);
106609
+ } catch (error44) {
106610
+ if (error44 instanceof Error && error44.message.startsWith("error parsing connection string")) {
106611
+ throw new Error(
106612
+ "error parsing connection string, format must be 'mariadb://[<user>[:<password>]@]<host>[:<port>]/[<db>[?<opt1>=<value1>[&<opt2>=<value2>]]]'"
106613
+ );
106614
+ }
106615
+ throw error44;
106616
+ }
106617
+ }
106591
106618
  async function getCapabilities(pool2) {
106592
106619
  const tag2 = "[js::getCapabilities]";
106593
106620
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prisma/query-plan-executor",
3
- "version": "7.10.0-dev.4",
3
+ "version": "7.10.0-dev.5",
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",
@@ -19,11 +19,11 @@
19
19
  "hono": "^4.12.23",
20
20
  "temporal-polyfill": "0.3.0",
21
21
  "zod": "4.1.3",
22
- "@prisma/adapter-pg": "7.10.0-dev.4",
23
- "@prisma/adapter-mariadb": "7.10.0-dev.4",
24
- "@prisma/client-engine-runtime": "7.10.0-dev.4",
25
- "@prisma/driver-adapter-utils": "7.10.0-dev.4",
26
- "@prisma/adapter-mssql": "7.10.0-dev.4"
22
+ "@prisma/adapter-pg": "7.10.0-dev.5",
23
+ "@prisma/adapter-mssql": "7.10.0-dev.5",
24
+ "@prisma/client-engine-runtime": "7.10.0-dev.5",
25
+ "@prisma/driver-adapter-utils": "7.10.0-dev.5",
26
+ "@prisma/adapter-mariadb": "7.10.0-dev.5"
27
27
  },
28
28
  "files": [
29
29
  "dist"