mirror of
https://github.com/Fabio286/antares.git
synced 2025-06-05 21:59:22 +02:00
fix: escape SQL parameters in update and delete for where clauses, fixes #964
This commit is contained in:
@@ -221,7 +221,7 @@ export default (connections: Record<string, antares.Client>) => {
|
|||||||
.update({ [params.field]: `= ${escapedParam}` })
|
.update({ [params.field]: `= ${escapedParam}` })
|
||||||
.schema(params.schema)
|
.schema(params.schema)
|
||||||
.from(params.table)
|
.from(params.table)
|
||||||
.where({ [params.primary]: `= ${id}` })
|
.where({ [params.primary]: `= ${sqlEscaper(id)}` })
|
||||||
.limit(1)
|
.limit(1)
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
@@ -233,7 +233,7 @@ export default (connections: Record<string, antares.Client>) => {
|
|||||||
|
|
||||||
for (const key in orgRow) {
|
for (const key in orgRow) {
|
||||||
if (typeof orgRow[key] === 'string')
|
if (typeof orgRow[key] === 'string')
|
||||||
orgRow[key] = ` = '${orgRow[key]}'`;
|
orgRow[key] = ` = '${sqlEscaper(orgRow[key])}'`;
|
||||||
else if (typeof orgRow[key] === 'object' && orgRow[key] !== null)
|
else if (typeof orgRow[key] === 'object' && orgRow[key] !== null)
|
||||||
orgRow[key] = formatJsonForSqlWhere(orgRow[key], connections[params.uid]._client);
|
orgRow[key] = formatJsonForSqlWhere(orgRow[key], connections[params.uid]._client);
|
||||||
else if (orgRow[key] === null)
|
else if (orgRow[key] === null)
|
||||||
@@ -290,7 +290,7 @@ export default (connections: Record<string, antares.Client>) => {
|
|||||||
for (const row of params.rows) {
|
for (const row of params.rows) {
|
||||||
for (const key in row) {
|
for (const key in row) {
|
||||||
if (typeof row[key] === 'string')
|
if (typeof row[key] === 'string')
|
||||||
row[key] = `'${row[key]}'`;
|
row[key] = `'${sqlEscaper(row[key])}'`;
|
||||||
|
|
||||||
if (row[key] === null)
|
if (row[key] === null)
|
||||||
row[key] = 'IS NULL';
|
row[key] = 'IS NULL';
|
||||||
|
Reference in New Issue
Block a user