Add Test Case for Single Quote and Fix Logic

Summary: Single quotes need to be double to be correctly recognized in queries. #thanks mweststrate for reminding me

Reviewed By: mweststrate

Differential Revision: D21908315

fbshipit-source-id: 6c13f9ddb527d1144cc3df90ba48bdb5f2ed4952
This commit is contained in:
Chaiwat Ekkaewnumchai
2020-06-08 08:57:33 -07:00
committed by Facebook GitHub Bot
parent a50c373631
commit 525d0e9925
2 changed files with 26 additions and 5 deletions

View File

@@ -51,13 +51,12 @@ export function constructQueryClause(
): string {
return Object.entries(values).reduce(
(clauses, [key, val]: [string, Value], idx) => {
const {type, value} = val;
const valueString =
type === 'null'
val.type === 'null'
? 'NULL'
: type === 'string' || type === 'blob'
? `'${value}'`
: `${value}`;
: val.type === 'string' || val.type === 'blob'
? `'${val.value.replace(/'/g, "''")}'`
: `${val.value}`;
if (idx <= 0) {
return `${key}=${valueString}`;
} else {