@atscript/db-mysql 0.1.177 → 0.1.179
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.cjs +24 -7
- package/dist/index.mjs +24 -7
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -784,8 +784,11 @@ const MYSQL_CONTENTION_CODES = {
|
|
|
784
784
|
};
|
|
785
785
|
/**
|
|
786
786
|
* `error` as the retryable `DbError` of its contention errno (deadlock,
|
|
787
|
-
* lock wait timeout, `NOWAIT` lock refusal), else `error` as is
|
|
788
|
-
* error is kept as `cause`.
|
|
787
|
+
* lock wait timeout, `NOWAIT` lock refusal), else `error` as is (a `DbError`
|
|
788
|
+
* too, so mapping twice is harmless); the driver error is kept as `cause`.
|
|
789
|
+
* Applied to every statement and to COMMIT — since 0.1.178 also to the
|
|
790
|
+
* schema steps that run on a connection of their own or unwrapped
|
|
791
|
+
* (`_withStrictSession`, `dropTableByName`).
|
|
789
792
|
*/
|
|
790
793
|
function mapContention(error) {
|
|
791
794
|
if (!error || typeof error !== "object") return error;
|
|
@@ -1016,6 +1019,8 @@ var MysqlAdapter = class MysqlAdapter extends _atscript_db.BaseDbAdapter {
|
|
|
1016
1019
|
} finally {
|
|
1017
1020
|
await conn.exec("SET SESSION sql_mode = @atscript_sql_mode");
|
|
1018
1021
|
}
|
|
1022
|
+
} catch (error) {
|
|
1023
|
+
throw mapContention(error);
|
|
1019
1024
|
} finally {
|
|
1020
1025
|
if (!tx) conn.release();
|
|
1021
1026
|
}
|
|
@@ -2527,13 +2532,25 @@ var MysqlAdapter = class MysqlAdapter extends _atscript_db.BaseDbAdapter {
|
|
|
2527
2532
|
const ddl = `DROP TABLE IF EXISTS ${quoteTableName(tableName)}`;
|
|
2528
2533
|
this._log(ddl);
|
|
2529
2534
|
const conn = await this.driver.getConnection();
|
|
2530
|
-
|
|
2535
|
+
const exec = contentionExec(conn);
|
|
2536
|
+
let failed = false;
|
|
2537
|
+
let failure;
|
|
2531
2538
|
try {
|
|
2532
|
-
await
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
|
|
2539
|
+
await exec.exec("SET FOREIGN_KEY_CHECKS = 0");
|
|
2540
|
+
await exec.exec(ddl);
|
|
2541
|
+
} catch (error) {
|
|
2542
|
+
failed = true;
|
|
2543
|
+
failure = error;
|
|
2544
|
+
}
|
|
2545
|
+
try {
|
|
2546
|
+
await exec.exec("SET FOREIGN_KEY_CHECKS = 1");
|
|
2547
|
+
} catch (error) {
|
|
2548
|
+
if (conn.destroy) conn.destroy();
|
|
2549
|
+
else conn.release();
|
|
2550
|
+
throw failed ? failure : error;
|
|
2536
2551
|
}
|
|
2552
|
+
conn.release();
|
|
2553
|
+
if (failed) throw failure;
|
|
2537
2554
|
}
|
|
2538
2555
|
async dropViewByName(viewName) {
|
|
2539
2556
|
const ddl = `DROP VIEW IF EXISTS ${quoteTableName(viewName)}`;
|
package/dist/index.mjs
CHANGED
|
@@ -783,8 +783,11 @@ const MYSQL_CONTENTION_CODES = {
|
|
|
783
783
|
};
|
|
784
784
|
/**
|
|
785
785
|
* `error` as the retryable `DbError` of its contention errno (deadlock,
|
|
786
|
-
* lock wait timeout, `NOWAIT` lock refusal), else `error` as is
|
|
787
|
-
* error is kept as `cause`.
|
|
786
|
+
* lock wait timeout, `NOWAIT` lock refusal), else `error` as is (a `DbError`
|
|
787
|
+
* too, so mapping twice is harmless); the driver error is kept as `cause`.
|
|
788
|
+
* Applied to every statement and to COMMIT — since 0.1.178 also to the
|
|
789
|
+
* schema steps that run on a connection of their own or unwrapped
|
|
790
|
+
* (`_withStrictSession`, `dropTableByName`).
|
|
788
791
|
*/
|
|
789
792
|
function mapContention(error) {
|
|
790
793
|
if (!error || typeof error !== "object") return error;
|
|
@@ -1015,6 +1018,8 @@ var MysqlAdapter = class MysqlAdapter extends BaseDbAdapter {
|
|
|
1015
1018
|
} finally {
|
|
1016
1019
|
await conn.exec("SET SESSION sql_mode = @atscript_sql_mode");
|
|
1017
1020
|
}
|
|
1021
|
+
} catch (error) {
|
|
1022
|
+
throw mapContention(error);
|
|
1018
1023
|
} finally {
|
|
1019
1024
|
if (!tx) conn.release();
|
|
1020
1025
|
}
|
|
@@ -2526,13 +2531,25 @@ var MysqlAdapter = class MysqlAdapter extends BaseDbAdapter {
|
|
|
2526
2531
|
const ddl = `DROP TABLE IF EXISTS ${quoteTableName(tableName)}`;
|
|
2527
2532
|
this._log(ddl);
|
|
2528
2533
|
const conn = await this.driver.getConnection();
|
|
2529
|
-
|
|
2534
|
+
const exec = contentionExec(conn);
|
|
2535
|
+
let failed = false;
|
|
2536
|
+
let failure;
|
|
2530
2537
|
try {
|
|
2531
|
-
await
|
|
2532
|
-
|
|
2533
|
-
|
|
2534
|
-
|
|
2538
|
+
await exec.exec("SET FOREIGN_KEY_CHECKS = 0");
|
|
2539
|
+
await exec.exec(ddl);
|
|
2540
|
+
} catch (error) {
|
|
2541
|
+
failed = true;
|
|
2542
|
+
failure = error;
|
|
2543
|
+
}
|
|
2544
|
+
try {
|
|
2545
|
+
await exec.exec("SET FOREIGN_KEY_CHECKS = 1");
|
|
2546
|
+
} catch (error) {
|
|
2547
|
+
if (conn.destroy) conn.destroy();
|
|
2548
|
+
else conn.release();
|
|
2549
|
+
throw failed ? failure : error;
|
|
2535
2550
|
}
|
|
2551
|
+
conn.release();
|
|
2552
|
+
if (failed) throw failure;
|
|
2536
2553
|
}
|
|
2537
2554
|
async dropViewByName(viewName) {
|
|
2538
2555
|
const ddl = `DROP VIEW IF EXISTS ${quoteTableName(viewName)}`;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atscript/db-mysql",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.179",
|
|
4
4
|
"description": "MySQL adapter for @atscript/db with mysql2 driver support.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"atscript",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"access": "public"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@atscript/db-sql-tools": "^0.1.
|
|
44
|
+
"@atscript/db-sql-tools": "^0.1.179"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@atscript/core": "^0.2.12",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"@atscript/typescript": "^0.2.12",
|
|
56
56
|
"@uniqu/core": "^0.2.2",
|
|
57
57
|
"mysql2": ">=3.0.0",
|
|
58
|
-
"@atscript/db": "^0.1.
|
|
58
|
+
"@atscript/db": "^0.1.179"
|
|
59
59
|
},
|
|
60
60
|
"peerDependenciesMeta": {
|
|
61
61
|
"mysql2": {
|