mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
improved postgresql sql parser support. support SIMILAR TO Operator. issue #1391
This commit is contained in:
@@ -58,6 +58,7 @@ public enum SQLBinaryOperator {
|
||||
ILike("ILIKE", 110),
|
||||
NotILike("NOT ILIKE", 110),
|
||||
AT_AT("@@", 110), // postgresql textsearch
|
||||
SIMILAR_TO("SIMILAR TO", 110),
|
||||
|
||||
RLike("RLIKE", 110),
|
||||
NotRLike("NOT RLIKE", 110),
|
||||
|
||||
@@ -226,6 +226,10 @@ public class Lexer {
|
||||
return token;
|
||||
}
|
||||
|
||||
public final String getDbType() {
|
||||
return this.dbType;
|
||||
}
|
||||
|
||||
public String info() {
|
||||
return this.token + " " + this.stringVal();
|
||||
}
|
||||
|
||||
@@ -1492,6 +1492,16 @@ public class SQLExprParser extends SQLParser {
|
||||
}
|
||||
} else if (lexer.token() == Token.IN) {
|
||||
expr = inRest(expr);
|
||||
} else if (JdbcConstants.POSTGRESQL.equals(lexer.dbType)
|
||||
&& identifierEquals("SIMILAR")) {
|
||||
lexer.nextToken();
|
||||
accept(Token.TO);
|
||||
|
||||
rightExp = equality();
|
||||
|
||||
rightExp = relationalRest(rightExp);
|
||||
|
||||
expr = new SQLBinaryOpExpr(expr, SQLBinaryOperator.SIMILAR_TO, rightExp, getDbType());
|
||||
}
|
||||
|
||||
return expr;
|
||||
|
||||
Reference in New Issue
Block a user