@prisma/adapter-mariadb 6.16.2 → 6.16.3

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
@@ -26,6 +26,7 @@ declare class MariaDbQueryable<Connection extends mariadb.Pool | mariadb.Connect
26
26
  queryRaw(query: SqlQuery): Promise<SqlResultSet>;
27
27
  executeRaw(query: SqlQuery): Promise<number>;
28
28
  protected performIO(query: SqlQuery): Promise<ArrayModeResult>;
29
+ protected onError(error: unknown): never;
29
30
  }
30
31
 
31
32
  export declare class PrismaMariaDb implements SqlDriverAdapterFactory {
package/dist/index.d.ts CHANGED
@@ -26,6 +26,7 @@ declare class MariaDbQueryable<Connection extends mariadb.Pool | mariadb.Connect
26
26
  queryRaw(query: SqlQuery): Promise<SqlResultSet>;
27
27
  executeRaw(query: SqlQuery): Promise<number>;
28
28
  protected performIO(query: SqlQuery): Promise<ArrayModeResult>;
29
+ protected onError(error: unknown): never;
29
30
  }
30
31
 
31
32
  export declare class PrismaMariaDb implements SqlDriverAdapterFactory {
package/dist/index.js CHANGED
@@ -345,25 +345,28 @@ var MariaDbQueryable = class {
345
345
  return await this.client.query(req, values);
346
346
  } catch (e) {
347
347
  const error = e;
348
- onError(error);
348
+ this.onError(error);
349
349
  }
350
350
  }
351
+ onError(error) {
352
+ debug("Error in performIO: %O", error);
353
+ throw new import_driver_adapter_utils2.DriverAdapterError(convertDriverError(error));
354
+ }
351
355
  };
352
- function onError(error) {
353
- debug("Error in performIO: %O", error);
354
- throw new import_driver_adapter_utils2.DriverAdapterError(convertDriverError(error));
355
- }
356
356
  var MariaDbTransaction = class extends MariaDbQueryable {
357
- constructor(conn, options) {
357
+ constructor(conn, options, cleanup) {
358
358
  super(conn);
359
359
  this.options = options;
360
+ this.cleanup = cleanup;
360
361
  }
361
362
  async commit() {
362
363
  debug(`[js::commit]`);
364
+ this.cleanup?.();
363
365
  await this.client.end();
364
366
  }
365
367
  async rollback() {
366
368
  debug(`[js::rollback]`);
369
+ this.cleanup?.();
367
370
  await this.client.end();
368
371
  }
369
372
  };
@@ -388,13 +391,17 @@ var PrismaMariaDbAdapter = class extends MariaDbQueryable {
388
391
  };
389
392
  const tag = "[js::startTransaction]";
390
393
  debug("%s options: %O", tag, options);
391
- const conn = await this.client.getConnection().catch((error) => onError(error));
392
- conn.on("error", (err) => {
394
+ const conn = await this.client.getConnection().catch((error) => this.onError(error));
395
+ const onError = (err) => {
393
396
  debug(`Error from connection: ${err.message} %O`, err);
394
397
  this.options?.onConnectionError?.(err);
395
- });
398
+ };
399
+ conn.on("error", onError);
400
+ const cleanup = () => {
401
+ conn.removeListener("error", onError);
402
+ };
396
403
  try {
397
- const tx = new MariaDbTransaction(conn, options);
404
+ const tx = new MariaDbTransaction(conn, options, cleanup);
398
405
  if (isolationLevel) {
399
406
  await tx.executeRaw({
400
407
  sql: `SET TRANSACTION ISOLATION LEVEL ${isolationLevel}`,
@@ -406,7 +413,8 @@ var PrismaMariaDbAdapter = class extends MariaDbQueryable {
406
413
  return tx;
407
414
  } catch (error) {
408
415
  await conn.end();
409
- onError(error);
416
+ cleanup();
417
+ this.onError(error);
410
418
  }
411
419
  }
412
420
  async dispose() {
package/dist/index.mjs CHANGED
@@ -309,25 +309,28 @@ var MariaDbQueryable = class {
309
309
  return await this.client.query(req, values);
310
310
  } catch (e) {
311
311
  const error = e;
312
- onError(error);
312
+ this.onError(error);
313
313
  }
314
314
  }
315
+ onError(error) {
316
+ debug("Error in performIO: %O", error);
317
+ throw new DriverAdapterError(convertDriverError(error));
318
+ }
315
319
  };
316
- function onError(error) {
317
- debug("Error in performIO: %O", error);
318
- throw new DriverAdapterError(convertDriverError(error));
319
- }
320
320
  var MariaDbTransaction = class extends MariaDbQueryable {
321
- constructor(conn, options) {
321
+ constructor(conn, options, cleanup) {
322
322
  super(conn);
323
323
  this.options = options;
324
+ this.cleanup = cleanup;
324
325
  }
325
326
  async commit() {
326
327
  debug(`[js::commit]`);
328
+ this.cleanup?.();
327
329
  await this.client.end();
328
330
  }
329
331
  async rollback() {
330
332
  debug(`[js::rollback]`);
333
+ this.cleanup?.();
331
334
  await this.client.end();
332
335
  }
333
336
  };
@@ -352,13 +355,17 @@ var PrismaMariaDbAdapter = class extends MariaDbQueryable {
352
355
  };
353
356
  const tag = "[js::startTransaction]";
354
357
  debug("%s options: %O", tag, options);
355
- const conn = await this.client.getConnection().catch((error) => onError(error));
356
- conn.on("error", (err) => {
358
+ const conn = await this.client.getConnection().catch((error) => this.onError(error));
359
+ const onError = (err) => {
357
360
  debug(`Error from connection: ${err.message} %O`, err);
358
361
  this.options?.onConnectionError?.(err);
359
- });
362
+ };
363
+ conn.on("error", onError);
364
+ const cleanup = () => {
365
+ conn.removeListener("error", onError);
366
+ };
360
367
  try {
361
- const tx = new MariaDbTransaction(conn, options);
368
+ const tx = new MariaDbTransaction(conn, options, cleanup);
362
369
  if (isolationLevel) {
363
370
  await tx.executeRaw({
364
371
  sql: `SET TRANSACTION ISOLATION LEVEL ${isolationLevel}`,
@@ -370,7 +377,8 @@ var PrismaMariaDbAdapter = class extends MariaDbQueryable {
370
377
  return tx;
371
378
  } catch (error) {
372
379
  await conn.end();
373
- onError(error);
380
+ cleanup();
381
+ this.onError(error);
374
382
  }
375
383
  }
376
384
  async dispose() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prisma/adapter-mariadb",
3
- "version": "6.16.2",
3
+ "version": "6.16.3",
4
4
  "description": "Prisma's driver adapter for \"mariadb\"",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -32,7 +32,7 @@
32
32
  "sideEffects": false,
33
33
  "dependencies": {
34
34
  "mariadb": "3.4.5",
35
- "@prisma/driver-adapter-utils": "6.16.2"
35
+ "@prisma/driver-adapter-utils": "6.16.3"
36
36
  },
37
37
  "scripts": {
38
38
  "dev": "DEV=true tsx helpers/build.ts",