Escape table names and keys
Summary: https://github.com/facebook/flipper/issues/1426 Changelog: [Databases] Fixed escaping of column names, see #1426 Reviewed By: jknoxville Differential Revision: D23293248 fbshipit-source-id: 6acbb87727524ba2bdc7973cad8c124a3ee026e6
This commit is contained in:
committed by
Facebook GitHub Bot
parent
39a465b8b8
commit
0b528f19ce
@@ -58,9 +58,9 @@ export function constructQueryClause(
|
||||
? `'${val.value.replace(/'/g, "''")}'`
|
||||
: `${val.value}`;
|
||||
if (idx <= 0) {
|
||||
return `${key}=${valueString}`;
|
||||
return `\`${key}\`=${valueString}`;
|
||||
} else {
|
||||
return `${clauses} ${connector} ${key}=${valueString}`;
|
||||
return `${clauses} ${connector} \`${key}\`=${valueString}`;
|
||||
}
|
||||
},
|
||||
'',
|
||||
@@ -72,7 +72,7 @@ export function constructUpdateQuery(
|
||||
where: {[key: string]: Value},
|
||||
change: {[key: string]: Value},
|
||||
): string {
|
||||
return `UPDATE ${table}
|
||||
return `UPDATE \`${table}\`
|
||||
SET ${constructQueryClause(change, ',')}
|
||||
WHERE ${constructQueryClause(where, 'AND')}`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user