This commit is contained in:
Tben
2023-08-29 08:02:21 +01:00
parent d8dddd5979
commit 9c61e83166
4 changed files with 27 additions and 1 deletions
+16
View File
@@ -89,6 +89,22 @@ async function addDbEntry({ dbFullName, tableName, data, tableSchema, duplicateC
console.log("DSQL: Encrypted value =>", value);
}
if (targetFieldSchema?.pattern) {
const pattern = new RegExp(targetFieldSchema.pattern, targetFieldSchema.patternFlags || "");
if (!pattern.test(value)) {
console.log("DSQL: Pattern not matched =>", value);
value = "";
}
}
if (typeof value === "string" && !value.match(/./i)) {
value = {
toSqlString: function () {
return "NULL";
},
};
}
insertKeysArray.push("`" + dataKey + "`");
if (typeof value === "object") {
+8
View File
@@ -81,6 +81,14 @@ async function updateDbEntry({ dbContext, paradigm, dbFullName, tableName, data,
};
}
if (targetFieldSchema?.pattern) {
const pattern = new RegExp(targetFieldSchema.pattern, targetFieldSchema.patternFlags || "");
if (!pattern.test(value)) {
console.log("DSQL: Pattern not matched =>", value);
value = "";
}
}
if (typeof value === "string" && !value.match(/./i)) {
value = {
toSqlString: function () {