Major version update. Major bugfixes. Security vulnerabilites fixed

This commit is contained in:
2026-10-14 03:02:07 +01:00
parent 4e47bd8ce0
commit 7c095f6f16
112 changed files with 2479 additions and 1219 deletions
+19 -21
View File
@@ -1,34 +1,32 @@
import DbClient from ".";
import dbHandler from "../db-handler";
import _ from "lodash";
import sqlGenerator from "../../utils/sql-generator";
export default async function DbDelete({ table, query, targetId, }) {
import { sqlIdent } from "../../utils/sql-safe";
export default async function DbDelete({ table, query, targetId, config, }) {
let sqlObj = null;
try {
let finalQuery = query || {};
if (targetId) {
finalQuery = _.merge(finalQuery, {
query: {
id: {
value: String(targetId),
},
},
});
}
const finalQuery = query || {};
sqlObj = sqlGenerator({
tableName: table,
genObject: finalQuery,
genObject: _.pick(finalQuery, ["query", "searchOperator"]),
targetId,
});
const whereClause = sqlObj.string.match(/WHERE .*/)?.[0];
const whereClause = sqlObj.where.string;
if (whereClause) {
let sql = `DELETE FROM ${table} ${whereClause}`;
let sql = `DELETE FROM ${sqlIdent(table, "table name")} ${whereClause}`;
sqlObj.string = sql;
const res = DbClient.run(sql, sqlObj.values);
sqlObj.values = sqlObj.where.values;
const res = dbHandler({
query: sql,
values: sqlObj.values,
config,
});
if (!res.success) {
return { ...res, debug: { sqlObj } };
}
return {
success: Boolean(res.changes),
postInsertReturn: {
affectedRows: res.changes,
insertId: Number(res.lastInsertRowid),
},
success: Boolean(res.postInsertReturn?.affectedRows),
postInsertReturn: res.postInsertReturn,
debug: {
sqlObj,
},