@oino-ts/db-mariadb 1.1.1 → 1.1.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 +8 -14
- package/dist/esm/OINODbMariadb.js +8 -14
- package/package.json +4 -4
- package/src/OINODbMariadb.ts +8 -14
|
@@ -307,13 +307,7 @@ class OINODbMariadb extends db_1.OINODb {
|
|
|
307
307
|
const sql = this._getValidateSql(this.dbParams.database);
|
|
308
308
|
const sql_res = await this._query(sql);
|
|
309
309
|
if (sql_res.isEmpty()) {
|
|
310
|
-
result.setError(400, "DB returned no rows for
|
|
311
|
-
}
|
|
312
|
-
else if (sql_res.getRow().length == 0) {
|
|
313
|
-
result.setError(400, "DB returned no values for database!", "OINODbMariadb.validate");
|
|
314
|
-
}
|
|
315
|
-
else if (sql_res.getRow()[0] == "0") {
|
|
316
|
-
result.setError(400, "DB returned no schema for database!", "OINODbMariadb.validate");
|
|
310
|
+
result.setError(400, "DB returned no rows for schema!", "OINODbMariadb.validate");
|
|
317
311
|
}
|
|
318
312
|
else {
|
|
319
313
|
this.isValidated = true;
|
|
@@ -369,12 +363,12 @@ class OINODbMariadb extends db_1.OINODb {
|
|
|
369
363
|
}
|
|
370
364
|
_getSchemaSql(dbName, tableName) {
|
|
371
365
|
const sql = `SELECT
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
366
|
+
C.COLUMN_NAME,
|
|
367
|
+
C.COLUMN_TYPE,
|
|
368
|
+
C.IS_NULLABLE,
|
|
369
|
+
C.COLUMN_KEY,
|
|
370
|
+
C.COLUMN_DEFAULT,
|
|
371
|
+
C.EXTRA,
|
|
378
372
|
KCU.CONSTRAINT_NAME AS ForeignKeyName
|
|
379
373
|
FROM information_schema.COLUMNS C
|
|
380
374
|
LEFT JOIN information_schema.KEY_COLUMN_USAGE KCU ON KCU.TABLE_SCHEMA = C.TABLE_SCHEMA AND KCU.TABLE_NAME = C.TABLE_NAME AND C.COLUMN_NAME = KCU.COLUMN_NAME and KCU.REFERENCED_TABLE_NAME IS NOT NULL
|
|
@@ -384,7 +378,7 @@ ORDER BY C.ORDINAL_POSITION;`;
|
|
|
384
378
|
}
|
|
385
379
|
_getValidateSql(dbName) {
|
|
386
380
|
const sql = `SELECT
|
|
387
|
-
Count(
|
|
381
|
+
Count(C.COLUMN_NAME) AS COLUMN_COUNT
|
|
388
382
|
FROM information_schema.COLUMNS C
|
|
389
383
|
LEFT JOIN information_schema.KEY_COLUMN_USAGE KCU ON KCU.TABLE_SCHEMA = C.TABLE_SCHEMA AND KCU.TABLE_NAME = C.TABLE_NAME AND C.COLUMN_NAME = KCU.COLUMN_NAME and KCU.REFERENCED_TABLE_NAME IS NOT NULL
|
|
390
384
|
WHERE C.TABLE_SCHEMA = '${dbName}';`;
|
|
@@ -304,13 +304,7 @@ export class OINODbMariadb extends OINODb {
|
|
|
304
304
|
const sql = this._getValidateSql(this.dbParams.database);
|
|
305
305
|
const sql_res = await this._query(sql);
|
|
306
306
|
if (sql_res.isEmpty()) {
|
|
307
|
-
result.setError(400, "DB returned no rows for
|
|
308
|
-
}
|
|
309
|
-
else if (sql_res.getRow().length == 0) {
|
|
310
|
-
result.setError(400, "DB returned no values for database!", "OINODbMariadb.validate");
|
|
311
|
-
}
|
|
312
|
-
else if (sql_res.getRow()[0] == "0") {
|
|
313
|
-
result.setError(400, "DB returned no schema for database!", "OINODbMariadb.validate");
|
|
307
|
+
result.setError(400, "DB returned no rows for schema!", "OINODbMariadb.validate");
|
|
314
308
|
}
|
|
315
309
|
else {
|
|
316
310
|
this.isValidated = true;
|
|
@@ -366,12 +360,12 @@ export class OINODbMariadb extends OINODb {
|
|
|
366
360
|
}
|
|
367
361
|
_getSchemaSql(dbName, tableName) {
|
|
368
362
|
const sql = `SELECT
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
363
|
+
C.COLUMN_NAME,
|
|
364
|
+
C.COLUMN_TYPE,
|
|
365
|
+
C.IS_NULLABLE,
|
|
366
|
+
C.COLUMN_KEY,
|
|
367
|
+
C.COLUMN_DEFAULT,
|
|
368
|
+
C.EXTRA,
|
|
375
369
|
KCU.CONSTRAINT_NAME AS ForeignKeyName
|
|
376
370
|
FROM information_schema.COLUMNS C
|
|
377
371
|
LEFT JOIN information_schema.KEY_COLUMN_USAGE KCU ON KCU.TABLE_SCHEMA = C.TABLE_SCHEMA AND KCU.TABLE_NAME = C.TABLE_NAME AND C.COLUMN_NAME = KCU.COLUMN_NAME and KCU.REFERENCED_TABLE_NAME IS NOT NULL
|
|
@@ -381,7 +375,7 @@ ORDER BY C.ORDINAL_POSITION;`;
|
|
|
381
375
|
}
|
|
382
376
|
_getValidateSql(dbName) {
|
|
383
377
|
const sql = `SELECT
|
|
384
|
-
Count(
|
|
378
|
+
Count(C.COLUMN_NAME) AS COLUMN_COUNT
|
|
385
379
|
FROM information_schema.COLUMNS C
|
|
386
380
|
LEFT JOIN information_schema.KEY_COLUMN_USAGE KCU ON KCU.TABLE_SCHEMA = C.TABLE_SCHEMA AND KCU.TABLE_NAME = C.TABLE_NAME AND C.COLUMN_NAME = KCU.COLUMN_NAME and KCU.REFERENCED_TABLE_NAME IS NOT NULL
|
|
387
381
|
WHERE C.TABLE_SCHEMA = '${dbName}';`;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oino-ts/db-mariadb",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"description": "OINO TS package for using Mariadb databases.",
|
|
5
5
|
"author": "Matias Kiviniemi (pragmatta)",
|
|
6
6
|
"license": "MPL-2.0",
|
|
@@ -21,12 +21,12 @@
|
|
|
21
21
|
"module": "./dist/esm/index.js",
|
|
22
22
|
"types": "./dist/types/index.d.ts",
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@oino-ts/common": "^1.1.
|
|
25
|
-
"@oino-ts/db": "^1.1.
|
|
24
|
+
"@oino-ts/common": "^1.1.2",
|
|
25
|
+
"@oino-ts/db": "^1.1.2",
|
|
26
26
|
"mariadb": "^3.2.3"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@types/bun": "^1.1.
|
|
29
|
+
"@types/bun": "^1.1.24",
|
|
30
30
|
"@types/node": "^20.12.7",
|
|
31
31
|
"typescript": "~5.9.0"
|
|
32
32
|
},
|
package/src/OINODbMariadb.ts
CHANGED
|
@@ -326,13 +326,7 @@ export class OINODbMariadb extends OINODb {
|
|
|
326
326
|
const sql = this._getValidateSql(this.dbParams.database)
|
|
327
327
|
const sql_res:OINODataSet = await this._query(sql)
|
|
328
328
|
if (sql_res.isEmpty()) {
|
|
329
|
-
result.setError(400, "DB returned no rows for
|
|
330
|
-
|
|
331
|
-
} else if (sql_res.getRow().length == 0) {
|
|
332
|
-
result.setError(400, "DB returned no values for database!", "OINODbMariadb.validate")
|
|
333
|
-
|
|
334
|
-
} else if (sql_res.getRow()[0] == "0") {
|
|
335
|
-
result.setError(400, "DB returned no schema for database!", "OINODbMariadb.validate")
|
|
329
|
+
result.setError(400, "DB returned no rows for schema!", "OINODbMariadb.validate")
|
|
336
330
|
|
|
337
331
|
} else {
|
|
338
332
|
this.isValidated = true
|
|
@@ -392,12 +386,12 @@ export class OINODbMariadb extends OINODb {
|
|
|
392
386
|
private _getSchemaSql(dbName:string, tableName:string):string {
|
|
393
387
|
const sql =
|
|
394
388
|
`SELECT
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
389
|
+
C.COLUMN_NAME,
|
|
390
|
+
C.COLUMN_TYPE,
|
|
391
|
+
C.IS_NULLABLE,
|
|
392
|
+
C.COLUMN_KEY,
|
|
393
|
+
C.COLUMN_DEFAULT,
|
|
394
|
+
C.EXTRA,
|
|
401
395
|
KCU.CONSTRAINT_NAME AS ForeignKeyName
|
|
402
396
|
FROM information_schema.COLUMNS C
|
|
403
397
|
LEFT JOIN information_schema.KEY_COLUMN_USAGE KCU ON KCU.TABLE_SCHEMA = C.TABLE_SCHEMA AND KCU.TABLE_NAME = C.TABLE_NAME AND C.COLUMN_NAME = KCU.COLUMN_NAME and KCU.REFERENCED_TABLE_NAME IS NOT NULL
|
|
@@ -409,7 +403,7 @@ ORDER BY C.ORDINAL_POSITION;`
|
|
|
409
403
|
private _getValidateSql(dbName:string):string {
|
|
410
404
|
const sql =
|
|
411
405
|
`SELECT
|
|
412
|
-
Count(
|
|
406
|
+
Count(C.COLUMN_NAME) AS COLUMN_COUNT
|
|
413
407
|
FROM information_schema.COLUMNS C
|
|
414
408
|
LEFT JOIN information_schema.KEY_COLUMN_USAGE KCU ON KCU.TABLE_SCHEMA = C.TABLE_SCHEMA AND KCU.TABLE_NAME = C.TABLE_NAME AND C.COLUMN_NAME = KCU.COLUMN_NAME and KCU.REFERENCED_TABLE_NAME IS NOT NULL
|
|
415
409
|
WHERE C.TABLE_SCHEMA = '${dbName}';`
|