@deterministic-code/datasources-mysql 0.1.3 → 0.1.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.
package/dist/connection.js
CHANGED
|
@@ -37,6 +37,7 @@ export class MysqlConnection {
|
|
|
37
37
|
this.client = await this.connect(this.url);
|
|
38
38
|
}
|
|
39
39
|
await this.client.query("SET SESSION sql_mode = CONCAT(@@sql_mode, ',ANSI_QUOTES')");
|
|
40
|
+
await this.client.query("SET time_zone = '+00:00'");
|
|
40
41
|
this.isOpen = true;
|
|
41
42
|
}
|
|
42
43
|
async close() {
|
|
@@ -45,7 +46,7 @@ export class MysqlConnection {
|
|
|
45
46
|
this.isOpen = false;
|
|
46
47
|
}
|
|
47
48
|
[Symbol.asyncDispose] = () => this.close();
|
|
48
|
-
async startTransaction(isolation = IsolationLevel.
|
|
49
|
+
async startTransaction(isolation = IsolationLevel.ReadCommitted) {
|
|
49
50
|
this.ensureOpen();
|
|
50
51
|
const client = this.require();
|
|
51
52
|
await client.query(`SET TRANSACTION ISOLATION LEVEL ${isoSql(isolation)}`);
|
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
import { TypeConverter } from "@deterministic-code/datasources";
|
|
2
2
|
const stamp = (date) => date.toISOString().replace("T", " ").replace("Z", "");
|
|
3
|
+
const utcDate = (text) => {
|
|
4
|
+
const iso = /[zZ]|[+-]\d{2}:\d{2}$/.test(text)
|
|
5
|
+
? text
|
|
6
|
+
: `${text.includes("T") ? text : text.replace(" ", "T")}Z`;
|
|
7
|
+
const date = new Date(iso);
|
|
8
|
+
return Number.isNaN(date.getTime()) ? text : date;
|
|
9
|
+
};
|
|
3
10
|
export class DateTimeConverter extends TypeConverter {
|
|
4
|
-
convert = (from) => typeof from === "string" ?
|
|
11
|
+
convert = (from) => typeof from === "string" ? utcDate(from) : from;
|
|
5
12
|
reverseConvert = (to) => to instanceof Date
|
|
6
13
|
? stamp(to)
|
|
7
14
|
: typeof to === "string" && /^\d{4}-\d{2}-\d{2}T/.test(to)
|
package/dist/i-mysql-engine.d.ts
CHANGED
package/dist/i-mysql-engine.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deterministic-code/datasources-mysql",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.js",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"access": "public"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@deterministic-code/datasources": "^0.1.
|
|
21
|
+
"@deterministic-code/datasources": "^0.1.5",
|
|
22
22
|
"mysql2": "^3.14.0"
|
|
23
23
|
}
|
|
24
24
|
}
|