[#7518] [#8451] Add SQL parser support for PostgreSQL ILIKE

This commit is contained in:
lukaseder 2019-03-26 15:00:37 +01:00
parent fc4860accc
commit b19d8ef9b6
2 changed files with 13 additions and 1 deletions

View File

@ -666,7 +666,7 @@ predicate =
| 'IN' '(' ( select | fields ) ')'
| 'BETWEEN' [ 'SYMMETRIC' ] concat 'AND' concat
| ( 'REGEXP' | 'RLIKE' | 'LIKE_REGEX' ) concat
| 'LIKE' concat [ 'ESCAPE' characterLiteral ]
| ( 'LIKE' | 'ILIKE' ) concat [ 'ESCAPE' characterLiteral ]
| 'SIMILAR' 'TO' concat [ 'ESCAPE' characterLiteral ]
)
| '@>' concat

View File

@ -4338,6 +4338,18 @@ final class ParserImpl implements Parser {
? ((Field) left).notLike(right)
: ((Field) left).like(right);
}
else if (left instanceof Field && parseKeywordIf(ctx, "ILIKE")) {
Field right = toField(ctx, parseConcat(ctx, null));
boolean escape = parseKeywordIf(ctx, "ESCAPE");
char character = escape ? parseCharacterLiteral(ctx) : ' ';
return escape
? not
? ((Field) left).notLikeIgnoreCase(right, character)
: ((Field) left).likeIgnoreCase(right, character)
: not
? ((Field) left).notLikeIgnoreCase(right)
: ((Field) left).likeIgnoreCase(right);
}
else if (left instanceof Field && (parseKeywordIf(ctx, "REGEXP")
|| parseKeywordIf(ctx, "RLIKE")
|| parseKeywordIf(ctx, "LIKE_REGEX"))) {