Bugfix: fix db-update return
This commit is contained in:
Vendored
+2
-21
@@ -65,33 +65,14 @@ export default async function DbUpdate({ table, data, query, targetId, config, }
|
||||
let updated_sql = ``;
|
||||
let updated_sql_values = [];
|
||||
updated_sql += `SELECT * FROM ${quoteIdentifier(table)} ${whereClause}`;
|
||||
updated_sql_values = [...updated_sql_values, ...sqlQueryObj.values];
|
||||
updated_sql += ` AND `;
|
||||
for (let i = 0; i < keys.length; i++) {
|
||||
const key = keys[i];
|
||||
if (!key)
|
||||
continue;
|
||||
if (key == "updated_at")
|
||||
continue;
|
||||
const isLast = i == keys.length - 1;
|
||||
updated_sql += ` ${quoteIdentifier(key)}=?`;
|
||||
updated_sql_values.push(finalData[key] ?? null);
|
||||
if (!isLast) {
|
||||
updated_sql += ` AND `;
|
||||
}
|
||||
}
|
||||
updated_sql_values = [...sqlQueryObj.values];
|
||||
const updated_res = await dbHandler({
|
||||
query: updated_sql,
|
||||
values: updated_sql_values,
|
||||
config,
|
||||
});
|
||||
const affected_rows = updated_res.payload?.length;
|
||||
return {
|
||||
...res,
|
||||
success: Boolean(affected_rows),
|
||||
insert_return: {
|
||||
affected_rows,
|
||||
},
|
||||
...updated_res,
|
||||
debug: {
|
||||
sqlObj,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user