badmfck-api-server 4.1.5 → 4.1.6
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.
|
@@ -3,7 +3,7 @@ import { BaseService } from "./BaseService";
|
|
|
3
3
|
import { IDBAdapter } from "./db/IDBAdapter";
|
|
4
4
|
export interface IDBQueryField {
|
|
5
5
|
name?: string | null;
|
|
6
|
-
value: string | number | boolean | null | undefined;
|
|
6
|
+
value: string | number | boolean | Date | null | undefined;
|
|
7
7
|
system?: boolean;
|
|
8
8
|
ignoreInInsert?: boolean;
|
|
9
9
|
ignoreInUpdate?: boolean;
|
|
@@ -151,7 +151,7 @@ class DBService extends BaseService_1.BaseService {
|
|
|
151
151
|
};
|
|
152
152
|
exports.REQ_DB.listener = async (req) => {
|
|
153
153
|
if (req.fields)
|
|
154
|
-
req.fields =
|
|
154
|
+
req.fields = structuredClone(req.fields);
|
|
155
155
|
const executionStartTime = Date.now();
|
|
156
156
|
if (!req.dbid && DBService.allInstances.length === 1 && DBService.allInstances[0].adapter) {
|
|
157
157
|
return await DBService.allInstances[0].adapter.query(req);
|
|
@@ -586,6 +586,8 @@ class MysqlAdapter {
|
|
|
586
586
|
queryField = { value: null, system: true };
|
|
587
587
|
if (typeof queryField === "string" || typeof queryField === "number" || typeof queryField === "boolean")
|
|
588
588
|
queryField = { value: queryField, system: false };
|
|
589
|
+
if (queryField instanceof Date)
|
|
590
|
+
queryField = { value: queryField, system: false };
|
|
589
591
|
if (queryField === null)
|
|
590
592
|
queryField = { value: null, system: true };
|
|
591
593
|
if (queryField.value === undefined) {
|
|
@@ -669,24 +671,26 @@ class MysqlAdapter {
|
|
|
669
671
|
field.__parsedValue = "NULL";
|
|
670
672
|
return "NULL";
|
|
671
673
|
}
|
|
672
|
-
if (
|
|
673
|
-
try {
|
|
674
|
-
value = JSON.stringify(value);
|
|
675
|
-
}
|
|
676
|
-
catch (e) {
|
|
677
|
-
console.error("Can't prepare JSON object", e);
|
|
678
|
-
value = "{}";
|
|
679
|
-
}
|
|
680
|
-
}
|
|
681
|
-
if (!system && typeof value === "string") {
|
|
682
|
-
value = promise_1.default.escape(value);
|
|
683
|
-
}
|
|
684
|
-
if (typeof value === "boolean")
|
|
685
|
-
value = value ? 1 : 0;
|
|
686
|
-
if (typeof value === "object" && value instanceof Date) {
|
|
674
|
+
if (value instanceof Date) {
|
|
687
675
|
const utcString = value.toISOString().slice(0, 19).replace('T', ' ');
|
|
688
676
|
value = promise_1.default.escape(utcString);
|
|
689
677
|
}
|
|
678
|
+
else {
|
|
679
|
+
if (!system && typeof value === "object") {
|
|
680
|
+
try {
|
|
681
|
+
value = JSON.stringify(value);
|
|
682
|
+
}
|
|
683
|
+
catch (e) {
|
|
684
|
+
console.error("Can't prepare JSON object", e);
|
|
685
|
+
value = "{}";
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
if (!system && typeof value === "string") {
|
|
689
|
+
value = promise_1.default.escape(value);
|
|
690
|
+
}
|
|
691
|
+
if (typeof value === "boolean")
|
|
692
|
+
value = value ? 1 : 0;
|
|
693
|
+
}
|
|
690
694
|
if (field.fields && typeof field.fields === "object" && value && typeof value === "string" && value.indexOf("@") !== -1) {
|
|
691
695
|
for (let key in field.fields) {
|
|
692
696
|
if (!field.fields[key])
|