fix(MySQL Node): Only escape table names when needed (#8246)

This commit is contained in:
Elias Meire
2024-01-10 14:41:00 +01:00
committed by GitHub
parent dce28f9cb9
commit 3b01eb60c9
8 changed files with 81 additions and 25 deletions

View File

@@ -8,7 +8,7 @@ import type {
import type { QueryRunner, QueryValues, QueryWithValues } from '../../helpers/interfaces';
import { AUTO_MAP, DATA_MODE } from '../../helpers/interfaces';
import { replaceEmptyStringsByNulls } from '../../helpers/utils';
import { escapeSqlIdentifier, replaceEmptyStringsByNulls } from '../../helpers/utils';
import { optionsCollection } from '../common.descriptions';
import { updateDisplayOptions } from '@utils/utilities';
@@ -182,14 +182,16 @@ export async function execute(
const updates: string[] = [];
for (const column of updateColumns) {
updates.push(`\`${column}\` = ?`);
updates.push(`${escapeSqlIdentifier(column)} = ?`);
values.push(item[column] as string);
}
const condition = `\`${columnToMatchOn}\` = ?`;
const condition = `${escapeSqlIdentifier(columnToMatchOn)} = ?`;
values.push(valueToMatchOn);
const query = `UPDATE \`${table}\` SET ${updates.join(', ')} WHERE ${condition}`;
const query = `UPDATE ${escapeSqlIdentifier(table)} SET ${updates.join(
', ',
)} WHERE ${condition}`;
queries.push({ query, values });
}