@prisma/adapter-mariadb 7.10.0-dev.9 → 7.10.0-integration-prisma7-project-closeout.7
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.js +22 -7
- package/dist/index.mjs +22 -7
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -190,10 +190,14 @@ function convertDriverError(error) {
|
|
|
190
190
|
function mapDriverError(error) {
|
|
191
191
|
switch (error.errno) {
|
|
192
192
|
case 1062: {
|
|
193
|
-
const
|
|
193
|
+
const rawKey = error.sqlMessage?.split(" ").pop()?.split("'").at(1);
|
|
194
|
+
const keyParts = rawKey?.split(".");
|
|
195
|
+
const table = keyParts && keyParts.length > 1 ? keyParts.slice(0, -1).join(".") : void 0;
|
|
196
|
+
const index = keyParts?.at(-1);
|
|
194
197
|
return {
|
|
195
198
|
kind: "UniqueConstraintViolation",
|
|
196
|
-
constraint: index !== void 0 ? { index } : void 0
|
|
199
|
+
constraint: index !== void 0 ? { index } : void 0,
|
|
200
|
+
table
|
|
197
201
|
};
|
|
198
202
|
}
|
|
199
203
|
case 1451:
|
|
@@ -371,7 +375,7 @@ var MariaDbTransaction = class extends MariaDbQueryable {
|
|
|
371
375
|
this.onError(err);
|
|
372
376
|
} finally {
|
|
373
377
|
this.cleanup?.();
|
|
374
|
-
await this.client
|
|
378
|
+
await releaseConnection(this.client);
|
|
375
379
|
}
|
|
376
380
|
}
|
|
377
381
|
async rollback() {
|
|
@@ -382,7 +386,7 @@ var MariaDbTransaction = class extends MariaDbQueryable {
|
|
|
382
386
|
this.onError(err);
|
|
383
387
|
} finally {
|
|
384
388
|
this.cleanup?.();
|
|
385
|
-
await this.client
|
|
389
|
+
await releaseConnection(this.client);
|
|
386
390
|
}
|
|
387
391
|
}
|
|
388
392
|
async createSavepoint(name2) {
|
|
@@ -424,7 +428,7 @@ var PrismaMariaDbAdapter = class extends MariaDbQueryable {
|
|
|
424
428
|
};
|
|
425
429
|
conn.on("error", onError);
|
|
426
430
|
const cleanup = () => {
|
|
427
|
-
conn.
|
|
431
|
+
conn.off("error", onError);
|
|
428
432
|
};
|
|
429
433
|
try {
|
|
430
434
|
const tx = new MariaDbTransaction(conn, this.mariadbOptions, options, cleanup);
|
|
@@ -438,8 +442,11 @@ var PrismaMariaDbAdapter = class extends MariaDbQueryable {
|
|
|
438
442
|
await tx.conn.query({ sql: "BEGIN" }).catch(this.onError.bind(this));
|
|
439
443
|
return tx;
|
|
440
444
|
} catch (error) {
|
|
441
|
-
|
|
442
|
-
|
|
445
|
+
try {
|
|
446
|
+
cleanup();
|
|
447
|
+
} finally {
|
|
448
|
+
await releaseConnection(conn);
|
|
449
|
+
}
|
|
443
450
|
this.onError(error);
|
|
444
451
|
}
|
|
445
452
|
}
|
|
@@ -557,6 +564,14 @@ function rewriteConnectionString(url) {
|
|
|
557
564
|
}
|
|
558
565
|
return url;
|
|
559
566
|
}
|
|
567
|
+
async function releaseConnection(conn) {
|
|
568
|
+
const poolConn = conn;
|
|
569
|
+
if (typeof poolConn.release === "function") {
|
|
570
|
+
await poolConn.release();
|
|
571
|
+
} else {
|
|
572
|
+
await conn.end();
|
|
573
|
+
}
|
|
574
|
+
}
|
|
560
575
|
// Annotate the CommonJS export names for ESM import in node:
|
|
561
576
|
0 && (module.exports = {
|
|
562
577
|
PrismaMariaDb
|
package/dist/index.mjs
CHANGED
|
@@ -154,10 +154,14 @@ function convertDriverError(error) {
|
|
|
154
154
|
function mapDriverError(error) {
|
|
155
155
|
switch (error.errno) {
|
|
156
156
|
case 1062: {
|
|
157
|
-
const
|
|
157
|
+
const rawKey = error.sqlMessage?.split(" ").pop()?.split("'").at(1);
|
|
158
|
+
const keyParts = rawKey?.split(".");
|
|
159
|
+
const table = keyParts && keyParts.length > 1 ? keyParts.slice(0, -1).join(".") : void 0;
|
|
160
|
+
const index = keyParts?.at(-1);
|
|
158
161
|
return {
|
|
159
162
|
kind: "UniqueConstraintViolation",
|
|
160
|
-
constraint: index !== void 0 ? { index } : void 0
|
|
163
|
+
constraint: index !== void 0 ? { index } : void 0,
|
|
164
|
+
table
|
|
161
165
|
};
|
|
162
166
|
}
|
|
163
167
|
case 1451:
|
|
@@ -335,7 +339,7 @@ var MariaDbTransaction = class extends MariaDbQueryable {
|
|
|
335
339
|
this.onError(err);
|
|
336
340
|
} finally {
|
|
337
341
|
this.cleanup?.();
|
|
338
|
-
await this.client
|
|
342
|
+
await releaseConnection(this.client);
|
|
339
343
|
}
|
|
340
344
|
}
|
|
341
345
|
async rollback() {
|
|
@@ -346,7 +350,7 @@ var MariaDbTransaction = class extends MariaDbQueryable {
|
|
|
346
350
|
this.onError(err);
|
|
347
351
|
} finally {
|
|
348
352
|
this.cleanup?.();
|
|
349
|
-
await this.client
|
|
353
|
+
await releaseConnection(this.client);
|
|
350
354
|
}
|
|
351
355
|
}
|
|
352
356
|
async createSavepoint(name2) {
|
|
@@ -388,7 +392,7 @@ var PrismaMariaDbAdapter = class extends MariaDbQueryable {
|
|
|
388
392
|
};
|
|
389
393
|
conn.on("error", onError);
|
|
390
394
|
const cleanup = () => {
|
|
391
|
-
conn.
|
|
395
|
+
conn.off("error", onError);
|
|
392
396
|
};
|
|
393
397
|
try {
|
|
394
398
|
const tx = new MariaDbTransaction(conn, this.mariadbOptions, options, cleanup);
|
|
@@ -402,8 +406,11 @@ var PrismaMariaDbAdapter = class extends MariaDbQueryable {
|
|
|
402
406
|
await tx.conn.query({ sql: "BEGIN" }).catch(this.onError.bind(this));
|
|
403
407
|
return tx;
|
|
404
408
|
} catch (error) {
|
|
405
|
-
|
|
406
|
-
|
|
409
|
+
try {
|
|
410
|
+
cleanup();
|
|
411
|
+
} finally {
|
|
412
|
+
await releaseConnection(conn);
|
|
413
|
+
}
|
|
407
414
|
this.onError(error);
|
|
408
415
|
}
|
|
409
416
|
}
|
|
@@ -521,6 +528,14 @@ function rewriteConnectionString(url) {
|
|
|
521
528
|
}
|
|
522
529
|
return url;
|
|
523
530
|
}
|
|
531
|
+
async function releaseConnection(conn) {
|
|
532
|
+
const poolConn = conn;
|
|
533
|
+
if (typeof poolConn.release === "function") {
|
|
534
|
+
await poolConn.release();
|
|
535
|
+
} else {
|
|
536
|
+
await conn.end();
|
|
537
|
+
}
|
|
538
|
+
}
|
|
524
539
|
export {
|
|
525
540
|
PrismaMariaDbAdapterFactory as PrismaMariaDb
|
|
526
541
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prisma/adapter-mariadb",
|
|
3
|
-
"version": "7.10.0-
|
|
3
|
+
"version": "7.10.0-integration-prisma7-project-closeout.7",
|
|
4
4
|
"description": "Prisma's driver adapter for \"mariadb\"",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -32,10 +32,10 @@
|
|
|
32
32
|
"sideEffects": false,
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"mariadb": "3.4.5",
|
|
35
|
-
"@prisma/driver-adapter-utils": "7.10.0-
|
|
35
|
+
"@prisma/driver-adapter-utils": "7.10.0-integration-prisma7-project-closeout.7"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"@prisma/debug": "7.10.0-
|
|
38
|
+
"@prisma/debug": "7.10.0-integration-prisma7-project-closeout.7"
|
|
39
39
|
},
|
|
40
40
|
"scripts": {
|
|
41
41
|
"dev": "DEV=true tsx helpers/build.ts",
|