mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
improved postgresql sql parser support. support Polygon Operators. issue #1391
This commit is contained in:
@@ -65,6 +65,7 @@ public enum SQLBinaryOperator {
|
||||
POSIX_Regular_Not_Match_POSIX_Regular_Match_Insensitive("!~*", 110),
|
||||
Array_Contains("@>", 110),
|
||||
Array_ContainedBy("<@", 110),
|
||||
SAME_AS("~=", 110),
|
||||
|
||||
RLike("RLIKE", 110),
|
||||
NotRLike("NOT RLIKE", 110),
|
||||
|
||||
@@ -650,6 +650,9 @@ public class Lexer {
|
||||
if (ch == '*') {
|
||||
scanChar();
|
||||
token = Token.TILDE_STAR;
|
||||
} else if (ch == '=') {
|
||||
scanChar();
|
||||
token = Token.TILDE_EQ; // postsql
|
||||
} else {
|
||||
token = Token.TILDE;
|
||||
}
|
||||
|
||||
@@ -51,6 +51,7 @@ import com.alibaba.druid.sql.ast.statement.SQLSelectItem;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLSelectOrderByItem;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLUnique;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLUpdateSetItem;
|
||||
import com.alibaba.druid.sql.dialect.postgresql.ast.expr.PGPolygonExpr;
|
||||
import com.alibaba.druid.util.JdbcConstants;
|
||||
|
||||
public class SQLExprParser extends SQLParser {
|
||||
@@ -1534,6 +1535,14 @@ public class SQLExprParser extends SQLParser {
|
||||
rightExp = relationalRest(rightExp);
|
||||
|
||||
expr = new SQLBinaryOpExpr(expr, SQLBinaryOperator.POSIX_Regular_Not_Match_POSIX_Regular_Match_Insensitive, rightExp, getDbType());
|
||||
} else if (lexer.token() == Token.TILDE_EQ) {
|
||||
lexer.nextToken();
|
||||
|
||||
rightExp = equality();
|
||||
|
||||
rightExp = relationalRest(rightExp);
|
||||
|
||||
expr = new SQLBinaryOpExpr(expr, SQLBinaryOperator.SAME_AS, rightExp, getDbType());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -303,6 +303,7 @@ public enum Token {
|
||||
BANG_TILDE_STAR("!~*"),
|
||||
TILDE("~"),
|
||||
TILDE_STAR("~*"),
|
||||
TILDE_EQ("~="),
|
||||
QUES("?"),
|
||||
COLON(":"),
|
||||
COLONCOLON(":"),
|
||||
|
||||
Reference in New Issue
Block a user