@oino-ts/db-mariadb 0.13.0 → 0.13.1
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 +10 -4
- package/dist/esm/OINODbMariadb.js +10 -4
- package/package.json +2 -2
- package/src/OINODbMariadb.ts +9 -4
|
@@ -233,11 +233,16 @@ class OINODbMariadb extends db_1.OINODb {
|
|
|
233
233
|
}
|
|
234
234
|
else if ((sqlType == "bit") && (sqlValue instanceof Buffer)) { // mariadb returns a buffer for bit-fields
|
|
235
235
|
const buf = sqlValue;
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
236
|
+
if (buf.length == 1) {
|
|
237
|
+
return buf.readUInt8(0) === 1;
|
|
238
|
+
}
|
|
239
|
+
else {
|
|
240
|
+
let result = "";
|
|
241
|
+
for (let i = 0; i < buf.length; i++) {
|
|
242
|
+
result += buf[i].toString(2).padStart(8, '0');
|
|
243
|
+
}
|
|
244
|
+
return result;
|
|
239
245
|
}
|
|
240
|
-
return result;
|
|
241
246
|
}
|
|
242
247
|
else {
|
|
243
248
|
return sqlValue;
|
|
@@ -372,6 +377,7 @@ WHERE C.TABLE_SCHEMA = '${dbName}';`;
|
|
|
372
377
|
const schema_res = await this.sqlSelect(this._getSchemaSql(this._params.database, api.params.tableName));
|
|
373
378
|
while (!schema_res.isEof()) {
|
|
374
379
|
const row = schema_res.getRow();
|
|
380
|
+
// console.log("OINODbMariadb.initializeApiDatamodel row", row)
|
|
375
381
|
const field_name = row[0]?.toString() || "";
|
|
376
382
|
const field_matches = OINODbMariadb._fieldLengthRegex.exec(row[1]?.toString() || "") || [];
|
|
377
383
|
const sql_type = field_matches[1] || "";
|
|
@@ -230,11 +230,16 @@ export class OINODbMariadb extends OINODb {
|
|
|
230
230
|
}
|
|
231
231
|
else if ((sqlType == "bit") && (sqlValue instanceof Buffer)) { // mariadb returns a buffer for bit-fields
|
|
232
232
|
const buf = sqlValue;
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
233
|
+
if (buf.length == 1) {
|
|
234
|
+
return buf.readUInt8(0) === 1;
|
|
235
|
+
}
|
|
236
|
+
else {
|
|
237
|
+
let result = "";
|
|
238
|
+
for (let i = 0; i < buf.length; i++) {
|
|
239
|
+
result += buf[i].toString(2).padStart(8, '0');
|
|
240
|
+
}
|
|
241
|
+
return result;
|
|
236
242
|
}
|
|
237
|
-
return result;
|
|
238
243
|
}
|
|
239
244
|
else {
|
|
240
245
|
return sqlValue;
|
|
@@ -369,6 +374,7 @@ WHERE C.TABLE_SCHEMA = '${dbName}';`;
|
|
|
369
374
|
const schema_res = await this.sqlSelect(this._getSchemaSql(this._params.database, api.params.tableName));
|
|
370
375
|
while (!schema_res.isEof()) {
|
|
371
376
|
const row = schema_res.getRow();
|
|
377
|
+
// console.log("OINODbMariadb.initializeApiDatamodel row", row)
|
|
372
378
|
const field_name = row[0]?.toString() || "";
|
|
373
379
|
const field_matches = OINODbMariadb._fieldLengthRegex.exec(row[1]?.toString() || "") || [];
|
|
374
380
|
const sql_type = field_matches[1] || "";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oino-ts/db-mariadb",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.1",
|
|
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.13.
|
|
24
|
+
"@oino-ts/db": "^0.13.1",
|
|
25
25
|
"mariadb": "^3.2.3"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
package/src/OINODbMariadb.ts
CHANGED
|
@@ -249,11 +249,15 @@ export class OINODbMariadb extends OINODb {
|
|
|
249
249
|
|
|
250
250
|
} else if ((sqlType == "bit") && (sqlValue instanceof Buffer)) { // mariadb returns a buffer for bit-fields
|
|
251
251
|
const buf:Buffer = sqlValue as Buffer
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
252
|
+
if (buf.length == 1) {
|
|
253
|
+
return buf.readUInt8(0) === 1
|
|
254
|
+
} else {
|
|
255
|
+
let result:string = ""
|
|
256
|
+
for (let i=0; i<buf.length; i++) {
|
|
257
|
+
result += buf[i].toString(2).padStart(8, '0')
|
|
258
|
+
}
|
|
259
|
+
return result
|
|
255
260
|
}
|
|
256
|
-
return result
|
|
257
261
|
|
|
258
262
|
} else {
|
|
259
263
|
return sqlValue
|
|
@@ -399,6 +403,7 @@ WHERE C.TABLE_SCHEMA = '${dbName}';`
|
|
|
399
403
|
const schema_res:OINODbDataSet = await this.sqlSelect(this._getSchemaSql(this._params.database, api.params.tableName))
|
|
400
404
|
while (!schema_res.isEof()) {
|
|
401
405
|
const row:OINODataRow = schema_res.getRow()
|
|
406
|
+
// console.log("OINODbMariadb.initializeApiDatamodel row", row)
|
|
402
407
|
const field_name:string = row[0]?.toString() || ""
|
|
403
408
|
const field_matches = OINODbMariadb._fieldLengthRegex.exec(row[1]?.toString() || "") || []
|
|
404
409
|
const sql_type:string = field_matches[1] || ""
|