@oino-ts/db-mariadb 0.6.1 → 0.7.0

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.
@@ -78,6 +78,13 @@ class OINOMariadbData extends db_1.OINODbDataSet {
78
78
  return db_1.OINODB_EMPTY_ROW;
79
79
  }
80
80
  }
81
+ /**
82
+ * Gets all rows of data.
83
+ *
84
+ */
85
+ async getAllRows() {
86
+ return this._rows; // at the moment theres no result streaming, so we can just return the rows
87
+ }
81
88
  }
82
89
  /**
83
90
  * Implementation of MariaDb/MySql-database.
@@ -98,7 +105,7 @@ class OINODbMariadb extends db_1.OINODb {
98
105
  if (this._params.type !== "OINODbMariadb") {
99
106
  throw new Error(db_1.OINO_ERROR_PREFIX + ": Not OINODbMariadb-type: " + this._params.type);
100
107
  }
101
- this._pool = mariadb_1.default.createPool({ host: this._params.url, database: this._params.database, port: this._params.port, user: this._params.user, password: this._params.password, acquireTimeout: 2000, debug: false, rowsAsArray: true });
108
+ this._pool = mariadb_1.default.createPool({ host: this._params.url, database: this._params.database, port: this._params.port, user: this._params.user, password: this._params.password, acquireTimeout: 2000, debug: false, rowsAsArray: true, multipleStatements: true });
102
109
  delete this._params.password; // do not store password in db object
103
110
  // this._pool.on("acquire", (conn: mariadb.Connection) => {
104
111
  // OINOLog.info("OINODbMariadb acquire", {conn:conn})
@@ -195,7 +202,7 @@ class OINODbMariadb extends db_1.OINODb {
195
202
  else if (cellValue === undefined) {
196
203
  return "UNDEFINED";
197
204
  }
198
- else if ((sqlType == "int") || (sqlType == "smallint") || (sqlType == "float")) {
205
+ else if ((sqlType == "int") || (sqlType == "smallint") || (sqlType == "float") || (sqlType == "double")) {
199
206
  return cellValue.toString();
200
207
  }
201
208
  else if ((sqlType == "longblob") || (sqlType == "binary") || (sqlType == "varbinary")) {
@@ -339,7 +346,7 @@ class OINODbMariadb extends db_1.OINODb {
339
346
  result = new OINOMariadbData(sql_res, []);
340
347
  }
341
348
  catch (e) {
342
- result = new OINOMariadbData([[]], [db_1.OINO_ERROR_PREFIX + " (sqlSelect): OINODbMariadb.sqlSelect exception in _db.query: " + e.message]);
349
+ result = new OINOMariadbData(db_1.OINODB_EMPTY_ROWS, [db_1.OINO_ERROR_PREFIX + " (sqlSelect): OINODbMariadb.sqlSelect exception in _db.query: " + e.message]);
343
350
  }
344
351
  db_1.OINOBenchmark.end("OINODb", "sqlSelect");
345
352
  return result;
@@ -359,7 +366,7 @@ class OINODbMariadb extends db_1.OINODb {
359
366
  result = new OINOMariadbData(sql_res, []);
360
367
  }
361
368
  catch (e) {
362
- result = new OINOMariadbData([[]], [db_1.OINO_ERROR_PREFIX + " (sqlExec): exception in _db.exec [" + e.message + "]"]);
369
+ result = new OINOMariadbData(db_1.OINODB_EMPTY_ROWS, [db_1.OINO_ERROR_PREFIX + " (sqlExec): exception in _db.exec [" + e.message + "]"]);
363
370
  }
364
371
  db_1.OINOBenchmark.end("OINODb", "sqlExec");
365
372
  return result;
@@ -75,6 +75,13 @@ class OINOMariadbData extends OINODbDataSet {
75
75
  return OINODB_EMPTY_ROW;
76
76
  }
77
77
  }
78
+ /**
79
+ * Gets all rows of data.
80
+ *
81
+ */
82
+ async getAllRows() {
83
+ return this._rows; // at the moment theres no result streaming, so we can just return the rows
84
+ }
78
85
  }
79
86
  /**
80
87
  * Implementation of MariaDb/MySql-database.
@@ -95,7 +102,7 @@ export class OINODbMariadb extends OINODb {
95
102
  if (this._params.type !== "OINODbMariadb") {
96
103
  throw new Error(OINO_ERROR_PREFIX + ": Not OINODbMariadb-type: " + this._params.type);
97
104
  }
98
- this._pool = mariadb.createPool({ host: this._params.url, database: this._params.database, port: this._params.port, user: this._params.user, password: this._params.password, acquireTimeout: 2000, debug: false, rowsAsArray: true });
105
+ this._pool = mariadb.createPool({ host: this._params.url, database: this._params.database, port: this._params.port, user: this._params.user, password: this._params.password, acquireTimeout: 2000, debug: false, rowsAsArray: true, multipleStatements: true });
99
106
  delete this._params.password; // do not store password in db object
100
107
  // this._pool.on("acquire", (conn: mariadb.Connection) => {
101
108
  // OINOLog.info("OINODbMariadb acquire", {conn:conn})
@@ -192,7 +199,7 @@ export class OINODbMariadb extends OINODb {
192
199
  else if (cellValue === undefined) {
193
200
  return "UNDEFINED";
194
201
  }
195
- else if ((sqlType == "int") || (sqlType == "smallint") || (sqlType == "float")) {
202
+ else if ((sqlType == "int") || (sqlType == "smallint") || (sqlType == "float") || (sqlType == "double")) {
196
203
  return cellValue.toString();
197
204
  }
198
205
  else if ((sqlType == "longblob") || (sqlType == "binary") || (sqlType == "varbinary")) {
@@ -336,7 +343,7 @@ export class OINODbMariadb extends OINODb {
336
343
  result = new OINOMariadbData(sql_res, []);
337
344
  }
338
345
  catch (e) {
339
- result = new OINOMariadbData([[]], [OINO_ERROR_PREFIX + " (sqlSelect): OINODbMariadb.sqlSelect exception in _db.query: " + e.message]);
346
+ result = new OINOMariadbData(OINODB_EMPTY_ROWS, [OINO_ERROR_PREFIX + " (sqlSelect): OINODbMariadb.sqlSelect exception in _db.query: " + e.message]);
340
347
  }
341
348
  OINOBenchmark.end("OINODb", "sqlSelect");
342
349
  return result;
@@ -356,7 +363,7 @@ export class OINODbMariadb extends OINODb {
356
363
  result = new OINOMariadbData(sql_res, []);
357
364
  }
358
365
  catch (e) {
359
- result = new OINOMariadbData([[]], [OINO_ERROR_PREFIX + " (sqlExec): exception in _db.exec [" + e.message + "]"]);
366
+ result = new OINOMariadbData(OINODB_EMPTY_ROWS, [OINO_ERROR_PREFIX + " (sqlExec): exception in _db.exec [" + e.message + "]"]);
360
367
  }
361
368
  OINOBenchmark.end("OINODb", "sqlExec");
362
369
  return result;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oino-ts/db-mariadb",
3
- "version": "0.6.1",
3
+ "version": "0.7.0",
4
4
  "description": "OINO TS package for using Mariadb databases.",
5
5
  "author": "Matias Kiviniemi (pragmatta)",
6
6
  "license": "MPL-2.0",
@@ -21,7 +21,7 @@
21
21
  "module": "./dist/esm/index.js",
22
22
  "types": "./dist/types/index.d.ts",
23
23
  "dependencies": {
24
- "@oino-ts/db": "^0.6.1",
24
+ "@oino-ts/db": "^0.7.0",
25
25
  "mariadb": "^3.2.3"
26
26
  },
27
27
  "devDependencies": {
@@ -82,6 +82,14 @@ class OINOMariadbData extends OINODbDataSet {
82
82
  return OINODB_EMPTY_ROW
83
83
  }
84
84
  }
85
+
86
+ /**
87
+ * Gets all rows of data.
88
+ *
89
+ */
90
+ async getAllRows(): Promise<OINODataRow[]> {
91
+ return this._rows // at the moment theres no result streaming, so we can just return the rows
92
+ }
85
93
  }
86
94
 
87
95
  /**
@@ -107,7 +115,7 @@ export class OINODbMariadb extends OINODb {
107
115
  if (this._params.type !== "OINODbMariadb") {
108
116
  throw new Error(OINO_ERROR_PREFIX + ": Not OINODbMariadb-type: " + this._params.type)
109
117
  }
110
- this._pool = mariadb.createPool({ host: this._params.url, database: this._params.database, port: this._params.port, user: this._params.user, password: this._params.password, acquireTimeout: 2000, debug:false, rowsAsArray: true })
118
+ this._pool = mariadb.createPool({ host: this._params.url, database: this._params.database, port: this._params.port, user: this._params.user, password: this._params.password, acquireTimeout: 2000, debug:false, rowsAsArray: true, multipleStatements: true })
111
119
  delete this._params.password // do not store password in db object
112
120
 
113
121
  // this._pool.on("acquire", (conn: mariadb.Connection) => {
@@ -210,7 +218,7 @@ export class OINODbMariadb extends OINODb {
210
218
  } else if (cellValue === undefined) {
211
219
  return "UNDEFINED"
212
220
 
213
- } else if ((sqlType == "int") || (sqlType == "smallint") || (sqlType == "float")) {
221
+ } else if ((sqlType == "int") || (sqlType == "smallint") || (sqlType == "float") || (sqlType == "double")) {
214
222
  return cellValue.toString()
215
223
 
216
224
  } else if ((sqlType == "longblob") || (sqlType == "binary") || (sqlType == "varbinary")) {
@@ -356,7 +364,7 @@ export class OINODbMariadb extends OINODb {
356
364
  result = new OINOMariadbData(sql_res, [])
357
365
 
358
366
  } catch (e:any) {
359
- result = new OINOMariadbData([[]], [OINO_ERROR_PREFIX + " (sqlSelect): OINODbMariadb.sqlSelect exception in _db.query: " + e.message])
367
+ result = new OINOMariadbData(OINODB_EMPTY_ROWS, [OINO_ERROR_PREFIX + " (sqlSelect): OINODbMariadb.sqlSelect exception in _db.query: " + e.message])
360
368
  }
361
369
  OINOBenchmark.end("OINODb", "sqlSelect")
362
370
  return result
@@ -377,7 +385,7 @@ export class OINODbMariadb extends OINODb {
377
385
  result = new OINOMariadbData(sql_res, [])
378
386
 
379
387
  } catch (e:any) {
380
- result = new OINOMariadbData([[]], [OINO_ERROR_PREFIX + " (sqlExec): exception in _db.exec [" + e.message + "]"])
388
+ result = new OINOMariadbData(OINODB_EMPTY_ROWS, [OINO_ERROR_PREFIX + " (sqlExec): exception in _db.exec [" + e.message + "]"])
381
389
  }
382
390
  OINOBenchmark.end("OINODb", "sqlExec")
383
391
  return result