Bugfix: fix db-update return
This commit is contained in:
@@ -113,22 +113,7 @@ export default async function DbUpdate<
|
||||
let updated_sql_values: any[] = [];
|
||||
|
||||
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,
|
||||
@@ -136,14 +121,8 @@ export default async function DbUpdate<
|
||||
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