This commit is contained in:
Tben 2023-07-07 16:55:56 +01:00
parent 4e2403272a
commit aa85d58daa
2 changed files with 4 additions and 14 deletions

View File

@ -42,7 +42,10 @@ module.exports = async function add({ dbFullName, tableName, data, tableSchema,
/** /**
* Handle function logic * Handle function logic
*/ */
if (duplicateColumnName && typeof duplicateColumnName === "string") { if (duplicateColumnName && typeof duplicateColumnName === "string") {
console.log("duplicateColumnName", duplicateColumnName);
const duplicateValue = await handler({ const duplicateValue = await handler({
queryString: `SELECT * FROM \`${tableName}\` WHERE \`${duplicateColumnName}\`=?`, queryString: `SELECT * FROM \`${tableName}\` WHERE \`${duplicateColumnName}\`=?`,
queryValuesArray: [duplicateColumnValue], queryValuesArray: [duplicateColumnValue],
@ -69,19 +72,6 @@ module.exports = async function add({ dbFullName, tableName, data, tableSchema,
encryptionSalt, encryptionSalt,
}); });
} }
} else if (duplicateColumnName && typeof duplicateColumnName === "object" && duplicateColumnValue && typeof duplicateColumnValue === "object") {
const duplicateArray = duplicateColumnName.map((dupColName, index) => {
return `\`${dupColName}\`='${duplicateColumnValue[index]}'`;
});
const duplicateValue = await handler({
queryString: `SELECT * FROM ${tableName} WHERE ${duplicateArray.join(" AND ")}`,
database: dbFullName,
});
if (duplicateValue && duplicateValue[0] && !update) {
return null;
}
} }
/** /**

View File

@ -1,6 +1,6 @@
{ {
"name": "datasquirel", "name": "datasquirel",
"version": "1.1.68", "version": "1.1.69",
"description": "Cloud-based SQL data management tool", "description": "Cloud-based SQL data management tool",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {