@oino-ts/db-mssql 0.8.0 → 0.8.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/OINODbMsSql.js +10 -10
- package/dist/esm/OINODbMsSql.js +10 -10
- package/package.json +2 -2
- package/src/OINODbMsSql.ts +10 -10
package/dist/cjs/OINODbMsSql.js
CHANGED
|
@@ -128,7 +128,7 @@ class OINODbMsSql extends db_1.OINODb {
|
|
|
128
128
|
});
|
|
129
129
|
delete this._params.password; // do not store password in db object
|
|
130
130
|
this._pool.on("error", (conn) => {
|
|
131
|
-
db_1.OINOLog.error("@
|
|
131
|
+
db_1.OINOLog.error("@oino-ts/db-mssql", "OINODbMsSql", "constructor", "OINODbMsSql error event", conn);
|
|
132
132
|
});
|
|
133
133
|
}
|
|
134
134
|
async _query(sql) {
|
|
@@ -255,7 +255,7 @@ class OINODbMsSql extends db_1.OINODb {
|
|
|
255
255
|
}
|
|
256
256
|
if ((limitCondition != "") && (limit_parts.length == 2)) {
|
|
257
257
|
if (orderCondition == "") {
|
|
258
|
-
db_1.OINOLog.error("@
|
|
258
|
+
db_1.OINOLog.error("@oino-ts/db-mssql", "OINODbMsSql", "printSqlSelect", "LIMIT without ORDER BY is not supported in MS SQL Server");
|
|
259
259
|
throw new Error(db_1.OINO_ERROR_PREFIX + "LIMIT without ORDER BY is not supported in MS SQL Server");
|
|
260
260
|
}
|
|
261
261
|
else {
|
|
@@ -263,7 +263,7 @@ class OINODbMsSql extends db_1.OINODb {
|
|
|
263
263
|
}
|
|
264
264
|
}
|
|
265
265
|
result += ";";
|
|
266
|
-
db_1.OINOLog.debug("@
|
|
266
|
+
db_1.OINOLog.debug("@oino-ts/db-mssql", "OINODbMsSql", "printSqlSelect", "Result", { sql: result });
|
|
267
267
|
return result;
|
|
268
268
|
}
|
|
269
269
|
/**
|
|
@@ -280,7 +280,7 @@ class OINODbMsSql extends db_1.OINODb {
|
|
|
280
280
|
catch (e) {
|
|
281
281
|
// ... error checks
|
|
282
282
|
result.setError(500, "Exception connecting to database: " + e.message, "OINODbMsSql.connect");
|
|
283
|
-
db_1.OINOLog.exception("@
|
|
283
|
+
db_1.OINOLog.exception("@oino-ts/db-mssql", "OINODbMsSql", "connect", "Exception", { message: e.message, stack: e.stack });
|
|
284
284
|
}
|
|
285
285
|
return Promise.resolve(result);
|
|
286
286
|
}
|
|
@@ -314,7 +314,7 @@ class OINODbMsSql extends db_1.OINODb {
|
|
|
314
314
|
}
|
|
315
315
|
catch (e) {
|
|
316
316
|
result.setError(500, "Exception in validating connection: " + e.message, "OINODbMsSql.validate");
|
|
317
|
-
db_1.OINOLog.exception("@
|
|
317
|
+
db_1.OINOLog.exception("@oino-ts/db-mssql", "OINODbMsSql", "validate", "Exception", { message: e.message, stack: e.stack });
|
|
318
318
|
}
|
|
319
319
|
db_1.OINOBenchmark.end("OINODb", "validate");
|
|
320
320
|
return result;
|
|
@@ -332,7 +332,7 @@ class OINODbMsSql extends db_1.OINODb {
|
|
|
332
332
|
result = await this._query(sql);
|
|
333
333
|
}
|
|
334
334
|
catch (e) {
|
|
335
|
-
db_1.OINOLog.exception("@
|
|
335
|
+
db_1.OINOLog.exception("@oino-ts/db-mssql", "OINODbMsSql", "sqlSelect", "SQL select exception", { message: e.message, stack: e.stack });
|
|
336
336
|
result = new OINOMsSqlData(db_1.OINODB_EMPTY_ROWS, [db_1.OINO_ERROR_PREFIX + " (sqlSelect): OINODbMsSql.sqlSelect exception in _db.query: " + e.message]);
|
|
337
337
|
}
|
|
338
338
|
db_1.OINOBenchmark.end("OINODb", "sqlSelect");
|
|
@@ -351,7 +351,7 @@ class OINODbMsSql extends db_1.OINODb {
|
|
|
351
351
|
result = await this._exec(sql);
|
|
352
352
|
}
|
|
353
353
|
catch (e) {
|
|
354
|
-
db_1.OINOLog.exception("@
|
|
354
|
+
db_1.OINOLog.exception("@oino-ts/db-mssql", "OINODbMsSql", "sqlExec", "SQL exec exception", { message: e.message, stack: e.stack });
|
|
355
355
|
result = new OINOMsSqlData(db_1.OINODB_EMPTY_ROWS, [db_1.OINO_ERROR_PREFIX + " (sqlExec): exception in _db.exec [" + e.message + "]"]);
|
|
356
356
|
}
|
|
357
357
|
db_1.OINOBenchmark.end("OINODb", "sqlExec");
|
|
@@ -421,7 +421,7 @@ WHERE C.TABLE_CATALOG = '${dbName}';`;
|
|
|
421
421
|
isNotNull: row[1] == "NO"
|
|
422
422
|
};
|
|
423
423
|
if (api.isFieldIncluded(field_name) == false) {
|
|
424
|
-
db_1.OINOLog.info("@
|
|
424
|
+
db_1.OINOLog.info("@oino-ts/db-mssql", "OINODbMsSql", "initializeApiDatamodel", "Field excluded in API parameters.", { field: field_name });
|
|
425
425
|
if (field_params.isPrimaryKey) {
|
|
426
426
|
throw new Error(db_1.OINO_ERROR_PREFIX + "Primary key field excluded in API parameters: " + field_name);
|
|
427
427
|
}
|
|
@@ -451,13 +451,13 @@ WHERE C.TABLE_CATALOG = '${dbName}';`;
|
|
|
451
451
|
api.datamodel.addField(new db_1.OINOBooleanDataField(this, field_name, sql_type, field_params));
|
|
452
452
|
}
|
|
453
453
|
else {
|
|
454
|
-
db_1.OINOLog.info("@
|
|
454
|
+
db_1.OINOLog.info("@oino-ts/db-mssql", "OINODbMsSql", "initializeApiDatamodel", "Unrecognized field type treated as string", { field_name: field_name, sql_type: sql_type, char_length: char_field_length, numeric_field_length1: numeric_field_length1, numeric_field_length2: numeric_field_length2, field_params: field_params });
|
|
455
455
|
api.datamodel.addField(new db_1.OINOStringDataField(this, field_name, sql_type, field_params, 0));
|
|
456
456
|
}
|
|
457
457
|
}
|
|
458
458
|
await schema_res.next();
|
|
459
459
|
}
|
|
460
|
-
db_1.OINOLog.info("@
|
|
460
|
+
db_1.OINOLog.info("@oino-ts/db-mssql", "OINODbMsSql", "initializeApiDatamodel", "\n" + api.datamodel.printDebug("\n"));
|
|
461
461
|
return Promise.resolve();
|
|
462
462
|
}
|
|
463
463
|
}
|
package/dist/esm/OINODbMsSql.js
CHANGED
|
@@ -125,7 +125,7 @@ export class OINODbMsSql extends OINODb {
|
|
|
125
125
|
});
|
|
126
126
|
delete this._params.password; // do not store password in db object
|
|
127
127
|
this._pool.on("error", (conn) => {
|
|
128
|
-
OINOLog.error("@
|
|
128
|
+
OINOLog.error("@oino-ts/db-mssql", "OINODbMsSql", "constructor", "OINODbMsSql error event", conn);
|
|
129
129
|
});
|
|
130
130
|
}
|
|
131
131
|
async _query(sql) {
|
|
@@ -252,7 +252,7 @@ export class OINODbMsSql extends OINODb {
|
|
|
252
252
|
}
|
|
253
253
|
if ((limitCondition != "") && (limit_parts.length == 2)) {
|
|
254
254
|
if (orderCondition == "") {
|
|
255
|
-
OINOLog.error("@
|
|
255
|
+
OINOLog.error("@oino-ts/db-mssql", "OINODbMsSql", "printSqlSelect", "LIMIT without ORDER BY is not supported in MS SQL Server");
|
|
256
256
|
throw new Error(OINO_ERROR_PREFIX + "LIMIT without ORDER BY is not supported in MS SQL Server");
|
|
257
257
|
}
|
|
258
258
|
else {
|
|
@@ -260,7 +260,7 @@ export class OINODbMsSql extends OINODb {
|
|
|
260
260
|
}
|
|
261
261
|
}
|
|
262
262
|
result += ";";
|
|
263
|
-
OINOLog.debug("@
|
|
263
|
+
OINOLog.debug("@oino-ts/db-mssql", "OINODbMsSql", "printSqlSelect", "Result", { sql: result });
|
|
264
264
|
return result;
|
|
265
265
|
}
|
|
266
266
|
/**
|
|
@@ -277,7 +277,7 @@ export class OINODbMsSql extends OINODb {
|
|
|
277
277
|
catch (e) {
|
|
278
278
|
// ... error checks
|
|
279
279
|
result.setError(500, "Exception connecting to database: " + e.message, "OINODbMsSql.connect");
|
|
280
|
-
OINOLog.exception("@
|
|
280
|
+
OINOLog.exception("@oino-ts/db-mssql", "OINODbMsSql", "connect", "Exception", { message: e.message, stack: e.stack });
|
|
281
281
|
}
|
|
282
282
|
return Promise.resolve(result);
|
|
283
283
|
}
|
|
@@ -311,7 +311,7 @@ export class OINODbMsSql extends OINODb {
|
|
|
311
311
|
}
|
|
312
312
|
catch (e) {
|
|
313
313
|
result.setError(500, "Exception in validating connection: " + e.message, "OINODbMsSql.validate");
|
|
314
|
-
OINOLog.exception("@
|
|
314
|
+
OINOLog.exception("@oino-ts/db-mssql", "OINODbMsSql", "validate", "Exception", { message: e.message, stack: e.stack });
|
|
315
315
|
}
|
|
316
316
|
OINOBenchmark.end("OINODb", "validate");
|
|
317
317
|
return result;
|
|
@@ -329,7 +329,7 @@ export class OINODbMsSql extends OINODb {
|
|
|
329
329
|
result = await this._query(sql);
|
|
330
330
|
}
|
|
331
331
|
catch (e) {
|
|
332
|
-
OINOLog.exception("@
|
|
332
|
+
OINOLog.exception("@oino-ts/db-mssql", "OINODbMsSql", "sqlSelect", "SQL select exception", { message: e.message, stack: e.stack });
|
|
333
333
|
result = new OINOMsSqlData(OINODB_EMPTY_ROWS, [OINO_ERROR_PREFIX + " (sqlSelect): OINODbMsSql.sqlSelect exception in _db.query: " + e.message]);
|
|
334
334
|
}
|
|
335
335
|
OINOBenchmark.end("OINODb", "sqlSelect");
|
|
@@ -348,7 +348,7 @@ export class OINODbMsSql extends OINODb {
|
|
|
348
348
|
result = await this._exec(sql);
|
|
349
349
|
}
|
|
350
350
|
catch (e) {
|
|
351
|
-
OINOLog.exception("@
|
|
351
|
+
OINOLog.exception("@oino-ts/db-mssql", "OINODbMsSql", "sqlExec", "SQL exec exception", { message: e.message, stack: e.stack });
|
|
352
352
|
result = new OINOMsSqlData(OINODB_EMPTY_ROWS, [OINO_ERROR_PREFIX + " (sqlExec): exception in _db.exec [" + e.message + "]"]);
|
|
353
353
|
}
|
|
354
354
|
OINOBenchmark.end("OINODb", "sqlExec");
|
|
@@ -418,7 +418,7 @@ WHERE C.TABLE_CATALOG = '${dbName}';`;
|
|
|
418
418
|
isNotNull: row[1] == "NO"
|
|
419
419
|
};
|
|
420
420
|
if (api.isFieldIncluded(field_name) == false) {
|
|
421
|
-
OINOLog.info("@
|
|
421
|
+
OINOLog.info("@oino-ts/db-mssql", "OINODbMsSql", "initializeApiDatamodel", "Field excluded in API parameters.", { field: field_name });
|
|
422
422
|
if (field_params.isPrimaryKey) {
|
|
423
423
|
throw new Error(OINO_ERROR_PREFIX + "Primary key field excluded in API parameters: " + field_name);
|
|
424
424
|
}
|
|
@@ -448,13 +448,13 @@ WHERE C.TABLE_CATALOG = '${dbName}';`;
|
|
|
448
448
|
api.datamodel.addField(new OINOBooleanDataField(this, field_name, sql_type, field_params));
|
|
449
449
|
}
|
|
450
450
|
else {
|
|
451
|
-
OINOLog.info("@
|
|
451
|
+
OINOLog.info("@oino-ts/db-mssql", "OINODbMsSql", "initializeApiDatamodel", "Unrecognized field type treated as string", { field_name: field_name, sql_type: sql_type, char_length: char_field_length, numeric_field_length1: numeric_field_length1, numeric_field_length2: numeric_field_length2, field_params: field_params });
|
|
452
452
|
api.datamodel.addField(new OINOStringDataField(this, field_name, sql_type, field_params, 0));
|
|
453
453
|
}
|
|
454
454
|
}
|
|
455
455
|
await schema_res.next();
|
|
456
456
|
}
|
|
457
|
-
OINOLog.info("@
|
|
457
|
+
OINOLog.info("@oino-ts/db-mssql", "OINODbMsSql", "initializeApiDatamodel", "\n" + api.datamodel.printDebug("\n"));
|
|
458
458
|
return Promise.resolve();
|
|
459
459
|
}
|
|
460
460
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oino-ts/db-mssql",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.1",
|
|
4
4
|
"description": "OINO TS package for using Microsoft Sql databases.",
|
|
5
5
|
"author": "Matias Kiviniemi (pragmatta)",
|
|
6
6
|
"license": "MPL-2.0",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"module": "./dist/esm/index.js",
|
|
23
23
|
"types": "./dist/types/index.d.ts",
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@oino-ts/db": "0.8.
|
|
25
|
+
"@oino-ts/db": "0.8.1",
|
|
26
26
|
"mssql": "^11.0.1"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
package/src/OINODbMsSql.ts
CHANGED
|
@@ -139,7 +139,7 @@ export class OINODbMsSql extends OINODb {
|
|
|
139
139
|
delete this._params.password // do not store password in db object
|
|
140
140
|
|
|
141
141
|
this._pool.on("error", (conn:any) => {
|
|
142
|
-
OINOLog.error("@
|
|
142
|
+
OINOLog.error("@oino-ts/db-mssql", "OINODbMsSql", "constructor", "OINODbMsSql error event", conn)
|
|
143
143
|
})
|
|
144
144
|
}
|
|
145
145
|
|
|
@@ -274,14 +274,14 @@ export class OINODbMsSql extends OINODb {
|
|
|
274
274
|
}
|
|
275
275
|
if ((limitCondition != "") && (limit_parts.length == 2)) {
|
|
276
276
|
if (orderCondition == "") {
|
|
277
|
-
OINOLog.error("@
|
|
277
|
+
OINOLog.error("@oino-ts/db-mssql", "OINODbMsSql", "printSqlSelect", "LIMIT without ORDER BY is not supported in MS SQL Server")
|
|
278
278
|
throw new Error(OINO_ERROR_PREFIX + "LIMIT without ORDER BY is not supported in MS SQL Server")
|
|
279
279
|
} else {
|
|
280
280
|
result += " OFFSET " + limit_parts[1] + " ROWS FETCH NEXT " + limit_parts[0] + " ROWS ONLY"
|
|
281
281
|
}
|
|
282
282
|
}
|
|
283
283
|
result += ";"
|
|
284
|
-
OINOLog.debug("@
|
|
284
|
+
OINOLog.debug("@oino-ts/db-mssql", "OINODbMsSql", "printSqlSelect", "Result", {sql:result})
|
|
285
285
|
return result;
|
|
286
286
|
}
|
|
287
287
|
|
|
@@ -299,7 +299,7 @@ export class OINODbMsSql extends OINODb {
|
|
|
299
299
|
} catch (e:any) {
|
|
300
300
|
// ... error checks
|
|
301
301
|
result.setError(500, "Exception connecting to database: " + e.message, "OINODbMsSql.connect")
|
|
302
|
-
OINOLog.exception("@
|
|
302
|
+
OINOLog.exception("@oino-ts/db-mssql", "OINODbMsSql", "connect", "Exception", {message:e.message, stack:e.stack})
|
|
303
303
|
}
|
|
304
304
|
return Promise.resolve(result)
|
|
305
305
|
}
|
|
@@ -333,7 +333,7 @@ export class OINODbMsSql extends OINODb {
|
|
|
333
333
|
}
|
|
334
334
|
} catch (e:any) {
|
|
335
335
|
result.setError(500, "Exception in validating connection: " + e.message, "OINODbMsSql.validate")
|
|
336
|
-
OINOLog.exception("@
|
|
336
|
+
OINOLog.exception("@oino-ts/db-mssql", "OINODbMsSql", "validate", "Exception", {message:e.message, stack:e.stack})
|
|
337
337
|
}
|
|
338
338
|
OINOBenchmark.end("OINODb", "validate")
|
|
339
339
|
return result
|
|
@@ -352,7 +352,7 @@ export class OINODbMsSql extends OINODb {
|
|
|
352
352
|
result = await this._query(sql)
|
|
353
353
|
|
|
354
354
|
} catch (e:any) {
|
|
355
|
-
OINOLog.exception("@
|
|
355
|
+
OINOLog.exception("@oino-ts/db-mssql", "OINODbMsSql", "sqlSelect", "SQL select exception", {message:e.message, stack:e.stack})
|
|
356
356
|
result = new OINOMsSqlData(OINODB_EMPTY_ROWS, [OINO_ERROR_PREFIX + " (sqlSelect): OINODbMsSql.sqlSelect exception in _db.query: " + e.message])
|
|
357
357
|
}
|
|
358
358
|
OINOBenchmark.end("OINODb", "sqlSelect")
|
|
@@ -372,7 +372,7 @@ export class OINODbMsSql extends OINODb {
|
|
|
372
372
|
result = await this._exec(sql)
|
|
373
373
|
|
|
374
374
|
} catch (e:any) {
|
|
375
|
-
OINOLog.exception("@
|
|
375
|
+
OINOLog.exception("@oino-ts/db-mssql", "OINODbMsSql", "sqlExec", "SQL exec exception", {message:e.message, stack:e.stack})
|
|
376
376
|
result = new OINOMsSqlData(OINODB_EMPTY_ROWS, [OINO_ERROR_PREFIX + " (sqlExec): exception in _db.exec [" + e.message + "]"])
|
|
377
377
|
}
|
|
378
378
|
OINOBenchmark.end("OINODb", "sqlExec")
|
|
@@ -448,7 +448,7 @@ WHERE C.TABLE_CATALOG = '${dbName}';`
|
|
|
448
448
|
isNotNull: row[1] == "NO"
|
|
449
449
|
}
|
|
450
450
|
if (api.isFieldIncluded(field_name) == false) {
|
|
451
|
-
OINOLog.info("@
|
|
451
|
+
OINOLog.info("@oino-ts/db-mssql", "OINODbMsSql", "initializeApiDatamodel", "Field excluded in API parameters.", {field:field_name})
|
|
452
452
|
if (field_params.isPrimaryKey) {
|
|
453
453
|
throw new Error(OINO_ERROR_PREFIX + "Primary key field excluded in API parameters: " + field_name)
|
|
454
454
|
}
|
|
@@ -477,13 +477,13 @@ WHERE C.TABLE_CATALOG = '${dbName}';`
|
|
|
477
477
|
api.datamodel.addField(new OINOBooleanDataField(this, field_name, sql_type, field_params))
|
|
478
478
|
|
|
479
479
|
} else {
|
|
480
|
-
OINOLog.info("@
|
|
480
|
+
OINOLog.info("@oino-ts/db-mssql", "OINODbMsSql", "initializeApiDatamodel", "Unrecognized field type treated as string", {field_name: field_name, sql_type:sql_type, char_length: char_field_length, numeric_field_length1:numeric_field_length1, numeric_field_length2:numeric_field_length2, field_params:field_params })
|
|
481
481
|
api.datamodel.addField(new OINOStringDataField(this, field_name, sql_type, field_params, 0))
|
|
482
482
|
}
|
|
483
483
|
}
|
|
484
484
|
await schema_res.next()
|
|
485
485
|
}
|
|
486
|
-
OINOLog.info("@
|
|
486
|
+
OINOLog.info("@oino-ts/db-mssql", "OINODbMsSql", "initializeApiDatamodel", "\n" + api.datamodel.printDebug("\n"))
|
|
487
487
|
return Promise.resolve()
|
|
488
488
|
}
|
|
489
489
|
|