@oino-ts/db-mariadb 1.6.0 → 1.6.2
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/cjs/OINODbMariadb.js +1 -1
- package/dist/esm/OINODbMariadb.js +1 -1
- package/package.json +39 -39
- package/src/OINODbMariadb.ts +6 -6
|
@@ -104,7 +104,7 @@ class OINODbMariadb extends db_1.OINODb {
|
|
|
104
104
|
if (this.dbParams.type !== "OINODbMariadb") {
|
|
105
105
|
throw new Error(common_1.OINO_ERROR_PREFIX + ": Not OINODbMariadb-type: " + this.dbParams.type);
|
|
106
106
|
}
|
|
107
|
-
this._pool = mariadb_1.default.createPool({ host: this.dbParams.url, database: this.dbParams.database, port: this.dbParams.port, user: this.dbParams.user, password: this.dbParams.password, acquireTimeout: 2000, debug: false, rowsAsArray: true, multipleStatements: false }); // statements are now executed individually with bind parameters, so stacked/multi-statement execution is disabled
|
|
107
|
+
this._pool = mariadb_1.default.createPool({ host: this.dbParams.url, database: this.dbParams.database, port: this.dbParams.port, user: this.dbParams.user, password: this.dbParams.password, acquireTimeout: 2000, debug: false, rowsAsArray: true, autoJsonMap: false, multipleStatements: false }); // autoJsonMap=false: return JSON columns as their original text instead of parsed objects (which would serialize as "[object Object]"); statements are now executed individually with bind parameters, so stacked/multi-statement execution is disabled
|
|
108
108
|
delete this.dbParams.password; // do not store password in db object
|
|
109
109
|
}
|
|
110
110
|
_parseFieldLength(fieldLengthStr) {
|
|
@@ -101,7 +101,7 @@ export class OINODbMariadb extends OINODb {
|
|
|
101
101
|
if (this.dbParams.type !== "OINODbMariadb") {
|
|
102
102
|
throw new Error(OINO_ERROR_PREFIX + ": Not OINODbMariadb-type: " + this.dbParams.type);
|
|
103
103
|
}
|
|
104
|
-
this._pool = mariadb.createPool({ host: this.dbParams.url, database: this.dbParams.database, port: this.dbParams.port, user: this.dbParams.user, password: this.dbParams.password, acquireTimeout: 2000, debug: false, rowsAsArray: true, multipleStatements: false }); // statements are now executed individually with bind parameters, so stacked/multi-statement execution is disabled
|
|
104
|
+
this._pool = mariadb.createPool({ host: this.dbParams.url, database: this.dbParams.database, port: this.dbParams.port, user: this.dbParams.user, password: this.dbParams.password, acquireTimeout: 2000, debug: false, rowsAsArray: true, autoJsonMap: false, multipleStatements: false }); // autoJsonMap=false: return JSON columns as their original text instead of parsed objects (which would serialize as "[object Object]"); statements are now executed individually with bind parameters, so stacked/multi-statement execution is disabled
|
|
105
105
|
delete this.dbParams.password; // do not store password in db object
|
|
106
106
|
}
|
|
107
107
|
_parseFieldLength(fieldLengthStr) {
|
package/package.json
CHANGED
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@oino-ts/db-mariadb",
|
|
3
|
-
"version": "1.6.
|
|
4
|
-
"description": "OINO TS package for using Mariadb databases.",
|
|
5
|
-
"author": "Matias Kiviniemi (pragmatta)",
|
|
6
|
-
"license": "MPL-2.0",
|
|
7
|
-
"repository": {
|
|
8
|
-
"type": "git",
|
|
9
|
-
"url": "https://github.com/pragmatta/oino-ts.git"
|
|
10
|
-
},
|
|
11
|
-
"keywords": [
|
|
12
|
-
"sql",
|
|
13
|
-
"database",
|
|
14
|
-
"rest-api",
|
|
15
|
-
"typescript",
|
|
16
|
-
"library",
|
|
17
|
-
"mariadb",
|
|
18
|
-
"mysql"
|
|
19
|
-
],
|
|
20
|
-
"main": "./dist/cjs/index.js",
|
|
21
|
-
"module": "./dist/esm/index.js",
|
|
22
|
-
"types": "./dist/types/index.d.ts",
|
|
23
|
-
"dependencies": {
|
|
24
|
-
"@oino-ts/common": "^1.6.
|
|
25
|
-
"@oino-ts/db": "^1.6.
|
|
26
|
-
"mariadb": "^3.
|
|
27
|
-
},
|
|
28
|
-
"devDependencies": {
|
|
29
|
-
"@types/bun": "^1.
|
|
30
|
-
"@types/node": "^20.
|
|
31
|
-
"typescript": "~5.9.
|
|
32
|
-
},
|
|
33
|
-
"files": [
|
|
34
|
-
"src/*.ts",
|
|
35
|
-
"dist/cjs/*.js",
|
|
36
|
-
"dist/esm/*.js",
|
|
37
|
-
"dist/types/*.d.ts"
|
|
38
|
-
]
|
|
39
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@oino-ts/db-mariadb",
|
|
3
|
+
"version": "1.6.2",
|
|
4
|
+
"description": "OINO TS package for using Mariadb databases.",
|
|
5
|
+
"author": "Matias Kiviniemi (pragmatta)",
|
|
6
|
+
"license": "MPL-2.0",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/pragmatta/oino-ts.git"
|
|
10
|
+
},
|
|
11
|
+
"keywords": [
|
|
12
|
+
"sql",
|
|
13
|
+
"database",
|
|
14
|
+
"rest-api",
|
|
15
|
+
"typescript",
|
|
16
|
+
"library",
|
|
17
|
+
"mariadb",
|
|
18
|
+
"mysql"
|
|
19
|
+
],
|
|
20
|
+
"main": "./dist/cjs/index.js",
|
|
21
|
+
"module": "./dist/esm/index.js",
|
|
22
|
+
"types": "./dist/types/index.d.ts",
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"@oino-ts/common": "^1.6.2",
|
|
25
|
+
"@oino-ts/db": "^1.6.2",
|
|
26
|
+
"mariadb": "^3.5.4"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"@types/bun": "^1.4.2",
|
|
30
|
+
"@types/node": "^20.19.43",
|
|
31
|
+
"typescript": "~5.9.3"
|
|
32
|
+
},
|
|
33
|
+
"files": [
|
|
34
|
+
"src/*.ts",
|
|
35
|
+
"dist/cjs/*.js",
|
|
36
|
+
"dist/esm/*.js",
|
|
37
|
+
"dist/types/*.d.ts"
|
|
38
|
+
]
|
|
39
|
+
}
|
package/src/OINODbMariadb.ts
CHANGED
|
@@ -10,7 +10,7 @@ import { OINODataSet, OINOBooleanDataField, OINONumberDataField, OINOStringDataF
|
|
|
10
10
|
|
|
11
11
|
import { OINODb, OINODbParams, OINODbSqlStatement } from "@oino-ts/db";
|
|
12
12
|
|
|
13
|
-
import mariadb from "mariadb";
|
|
13
|
+
import mariadb, { type Pool, type PoolConnection } from "mariadb";
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* Implmentation of OINODataSet for MariaDb.
|
|
@@ -104,7 +104,7 @@ export class OINODbMariadb extends OINODb {
|
|
|
104
104
|
private static _connectionExceptionMessageRegex = /\(([^\)]*)\) (.*)/i
|
|
105
105
|
private static _sqlExceptionMessageRegex = /\(([^\)]*)\) (.*)\nsql\:(.*)?/i
|
|
106
106
|
|
|
107
|
-
private _pool:
|
|
107
|
+
private _pool:Pool
|
|
108
108
|
|
|
109
109
|
/**
|
|
110
110
|
* Constructor of `OINODbMariadb`
|
|
@@ -116,7 +116,7 @@ export class OINODbMariadb extends OINODb {
|
|
|
116
116
|
if (this.dbParams.type !== "OINODbMariadb") {
|
|
117
117
|
throw new Error(OINO_ERROR_PREFIX + ": Not OINODbMariadb-type: " + this.dbParams.type)
|
|
118
118
|
}
|
|
119
|
-
this._pool = mariadb.createPool({ host: this.dbParams.url, database: this.dbParams.database, port: this.dbParams.port, user: this.dbParams.user, password: this.dbParams.password, acquireTimeout: 2000, debug:false, rowsAsArray: true, multipleStatements: false }) // statements are now executed individually with bind parameters, so stacked/multi-statement execution is disabled
|
|
119
|
+
this._pool = mariadb.createPool({ host: this.dbParams.url, database: this.dbParams.database, port: this.dbParams.port, user: this.dbParams.user, password: this.dbParams.password, acquireTimeout: 2000, debug:false, rowsAsArray: true, autoJsonMap: false, multipleStatements: false }) // autoJsonMap=false: return JSON columns as their original text instead of parsed objects (which would serialize as "[object Object]"); statements are now executed individually with bind parameters, so stacked/multi-statement execution is disabled
|
|
120
120
|
delete this.dbParams.password // do not store password in db object
|
|
121
121
|
}
|
|
122
122
|
|
|
@@ -129,7 +129,7 @@ export class OINODbMariadb extends OINODb {
|
|
|
129
129
|
}
|
|
130
130
|
|
|
131
131
|
private async _query(sql:string, params?:OINODataCell[]):Promise<OINODataSet> {
|
|
132
|
-
let connection:
|
|
132
|
+
let connection:PoolConnection|null = null
|
|
133
133
|
let rows:OINODataRow[] = OINO_EMPTY_ROWS
|
|
134
134
|
try {
|
|
135
135
|
connection = await this._pool.getConnection()
|
|
@@ -151,7 +151,7 @@ export class OINODbMariadb extends OINODb {
|
|
|
151
151
|
}
|
|
152
152
|
|
|
153
153
|
private async _exec(sql:string, params?:OINODataCell[]):Promise<OINODataSet> {
|
|
154
|
-
let connection:
|
|
154
|
+
let connection:PoolConnection|null = null
|
|
155
155
|
let rows:OINODataRow[] = OINO_EMPTY_ROWS
|
|
156
156
|
try {
|
|
157
157
|
connection = await this._pool.getConnection()
|
|
@@ -323,7 +323,7 @@ export class OINODbMariadb extends OINODb {
|
|
|
323
323
|
if (this.isConnected) {
|
|
324
324
|
return result
|
|
325
325
|
}
|
|
326
|
-
let connection:
|
|
326
|
+
let connection:PoolConnection|null = null
|
|
327
327
|
try {
|
|
328
328
|
// make sure that any items are correctly URL encoded in the connection string
|
|
329
329
|
connection = await this._pool.getConnection()
|