fix variable escaping

This commit is contained in:
Sven Klemm
2018-08-15 11:37:30 +02:00
parent a2f4441f9d
commit 907e8fd77c

View File

@ -48,7 +48,11 @@ export default class PostgresQuery {
} }
quoteLiteral(value) { quoteLiteral(value) {
return "'" + value.replace("'", "''") + "'"; return "'" + this.escapeLiteral(value) + "'";
}
escapeLiteral(value) {
return value.replace("'", "''");
} }
hasTimeGroup() { hasTimeGroup() {
@ -62,7 +66,7 @@ export default class PostgresQuery {
interpolateQueryStr(value, variable, defaultFormatFn) { interpolateQueryStr(value, variable, defaultFormatFn) {
// if no multi or include all do not regexEscape // if no multi or include all do not regexEscape
if (!variable.multi && !variable.includeAll) { if (!variable.multi && !variable.includeAll) {
return value; return this.escapeLiteral(value);
} }
if (typeof value === 'string') { if (typeof value === 'string') {