@inflector/optima 1.0.13 → 1.0.14
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/index.js +20 -5
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -403,11 +403,17 @@ var regexp = (value) => cond().regexp(value);
|
|
|
403
403
|
var notRegexp = (value) => cond().notRegexp(value);
|
|
404
404
|
var escape = (val) => {
|
|
405
405
|
if (val === null || val === void 0) return "NULL";
|
|
406
|
+
if (typeof val === "bigint") return val.toString();
|
|
406
407
|
if (typeof val === "string") return `'${val.replace(/'/g, "''")}'`;
|
|
407
408
|
if (val instanceof Date) return `'${val.toISOString()}'`;
|
|
408
409
|
if (typeof val === "boolean") return val ? "TRUE" : "FALSE";
|
|
409
|
-
if (typeof val === "object")
|
|
410
|
-
|
|
410
|
+
if (typeof val === "object") {
|
|
411
|
+
const safe = JSON.stringify(
|
|
412
|
+
val,
|
|
413
|
+
(_, v) => typeof v === "bigint" ? v.toString() : v
|
|
414
|
+
);
|
|
415
|
+
return `'${safe.replace(/'/g, "''")}'`;
|
|
416
|
+
}
|
|
411
417
|
return String(val);
|
|
412
418
|
};
|
|
413
419
|
var SQL_GENERATORS = {
|
|
@@ -719,7 +725,11 @@ ${valuesBlock}${isReturning ? "\nRETURNING *" : ""};`;
|
|
|
719
725
|
const Result = await (await this.Connection.run(sql)).getRowObjects();
|
|
720
726
|
if (Result.length != 0) {
|
|
721
727
|
if (data.returning) {
|
|
722
|
-
this.notifyChange({
|
|
728
|
+
this.notifyChange({
|
|
729
|
+
event: "Update",
|
|
730
|
+
data: Result,
|
|
731
|
+
time: /* @__PURE__ */ new Date()
|
|
732
|
+
});
|
|
723
733
|
} else {
|
|
724
734
|
const Updated = PotentialyUpdated;
|
|
725
735
|
const UpdatedPromises = Updated.map(
|
|
@@ -749,7 +759,11 @@ ${valuesBlock}${isReturning ? "\nRETURNING *" : ""};`;
|
|
|
749
759
|
const Result = await (await this.Connection.run(sql)).getRowObjects();
|
|
750
760
|
if (Result.length != 0) {
|
|
751
761
|
if (data.returning) {
|
|
752
|
-
this.notifyChange({
|
|
762
|
+
this.notifyChange({
|
|
763
|
+
event: "Delete",
|
|
764
|
+
data: Result,
|
|
765
|
+
time: /* @__PURE__ */ new Date()
|
|
766
|
+
});
|
|
753
767
|
} else {
|
|
754
768
|
const DeletedRecords = PotentiallyDeleted;
|
|
755
769
|
this.notifyChange({
|
|
@@ -815,7 +829,8 @@ ${valuesBlock}${isReturning ? "\nRETURNING *" : ""};`;
|
|
|
815
829
|
if (!fn(data[field])) {
|
|
816
830
|
throw new Error(
|
|
817
831
|
`Validation failed for field '${field}' : The value '${JSON.stringify(
|
|
818
|
-
data[field]
|
|
832
|
+
data[field],
|
|
833
|
+
(_, v) => typeof v === "bigint" ? v.toString() : v
|
|
819
834
|
)}' doesn't pass the validate function`
|
|
820
835
|
);
|
|
821
836
|
}
|