不要怂,就是干,撸起袖子干!

Commit 93a09b73 by Chris Kalmar Committed by Felix Becker

fix(querygenerator): add parentheses to queries when using ALL with LIKE (#7989)

1 parent 5611a26c
......@@ -2304,8 +2304,11 @@ const QueryGenerator = {
if (escapeValue) {
value = this.escape(value, field, escapeOptions);
//if ANY is used with like, add parentheses to generate correct query
if (escapeOptions.acceptStrings && comparator.indexOf('ANY') > comparator.indexOf('LIKE')) {
// if ANY or ALL is used with like, add parentheses to generate correct query
if (escapeOptions.acceptStrings && (
comparator.indexOf('ANY') > comparator.indexOf('LIKE') ||
comparator.indexOf('ALL') > comparator.indexOf('LIKE')
)) {
value = '(' + value + ')';
}
} else if (escapeOptions.acceptRegExp) {
......
......@@ -603,11 +603,35 @@ suite(Support.getTestDialectTeaser('SQL'), () => {
});
testsql('userId', {
$like: {
$all: ['foo', 'bar', 'baz']
}
}, {
postgres: "\"userId\" LIKE ALL (ARRAY['foo','bar','baz'])"
});
testsql('userId', {
$iLike: {
$all: ['foo', 'bar', 'baz']
}
}, {
postgres: "\"userId\" ILIKE ALL (ARRAY['foo','bar','baz'])"
});
testsql('userId', {
$notLike: {
$all: ['foo', 'bar', 'baz']
}
}, {
postgres: "\"userId\" NOT LIKE ALL (ARRAY['foo','bar','baz'])"
});
testsql('userId', {
$notILike: {
$all: ['foo', 'bar', 'baz']
}
}, {
postgres: "\"userId\" NOT ILIKE ALL ARRAY['foo','bar','baz']"
postgres: "\"userId\" NOT ILIKE ALL (ARRAY['foo','bar','baz'])"
});
});
});
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!