improved sql parser for postgresql

This commit is contained in:
wenshao
2014-11-16 15:35:47 +08:00
parent 6983fa6d1f
commit 8e6dbe121b
29 changed files with 655 additions and 74 deletions
@@ -28,16 +28,25 @@ public class SQLBinaryOpExpr extends SQLExprImpl implements Serializable {
private SQLExpr left;
private SQLExpr right;
private SQLBinaryOperator operator;
private String dbType;
public SQLBinaryOpExpr(){
}
public SQLBinaryOpExpr(SQLExpr left, SQLBinaryOperator operator, SQLExpr right){
public SQLBinaryOpExpr(String dbType){
this.dbType = dbType;
}
public SQLBinaryOpExpr(SQLExpr left, SQLBinaryOperator operator, SQLExpr right){
this(left, operator, right, null);
}
public SQLBinaryOpExpr(SQLExpr left, SQLBinaryOperator operator, SQLExpr right, String dbType){
setLeft(left);
setRight(right);
this.operator = operator;
this.dbType = dbType;
}
public SQLBinaryOpExpr(SQLExpr left, SQLExpr right, SQLBinaryOperator operator){
@@ -47,6 +56,14 @@ public class SQLBinaryOpExpr extends SQLExprImpl implements Serializable {
this.operator = operator;
}
public String getDbType() {
return dbType;
}
public void setDbType(String dbType) {
this.dbType = dbType;
}
public SQLExpr getLeft() {
return this.left;
}
@@ -129,6 +146,6 @@ public class SQLBinaryOpExpr extends SQLExprImpl implements Serializable {
}
public String toString() {
return SQLUtils.toSQLString(this);
return SQLUtils.toSQLString(this, getDbType());
}
}
@@ -117,4 +117,8 @@ public enum SQLBinaryOperator {
return false;
}
}
public boolean isLogical() {
return this == BooleanAnd || this == BooleanOr || this == BooleanXor;
}
}
@@ -24,7 +24,9 @@ public enum SQLUnaryOperator {
ConnectByRoot("CONNECT BY"), //
BINARY("BINARY"), //
RAW("RAW"), //
NOT("NOT");
NOT("NOT"),
Pound("#") // Number of points in path or polygon
;
public final String name;