wrap field and table names in backticks for sql queries

This commit is contained in:
Stephanie Yang 2021-07-12 21:08:42 -05:00
parent 12fd95d8cf
commit 97ee1b91ef

View file

@ -110,7 +110,13 @@ export const QueryContainer: FC<{}> = () => {
setLoading(false);
}
} else {
querySQL(query, handleQueryMessages, handleQueryEnd);
let queryArr = query.split(' ');
queryArr.forEach((word, idx) => {
if (word.includes('-') && !word.includes('`')) {
queryArr[idx] = `\`${queryArr[idx]}\``;
}
});
querySQL(queryArr.join(' '), handleQueryMessages, handleQueryEnd);
}
}
};