improved sql parser.

This commit is contained in:
wenshao
2017-06-29 15:19:57 +08:00
parent 2f6e406e33
commit bdbc39ec3c
39 changed files with 963 additions and 185 deletions
@@ -22,9 +22,9 @@ import com.alibaba.druid.sql.visitor.SQLASTVisitor;
public class SQLIdentifierExpr extends SQLExprImpl implements SQLName {
private String name;
protected String name;
private transient String lowerName;
private transient String lowerName;
private transient Boolean parameter;
public SQLIdentifierExpr(){
@@ -132,4 +132,8 @@ public class SQLIdentifierExpr extends SQLExprImpl implements SQLName {
public SQLIdentifierExpr clone() {
return new SQLIdentifierExpr(this.name);
}
public String normalizedName() {
return SQLUtils.normalize(name);
}
}
@@ -15,6 +15,7 @@
*/
package com.alibaba.druid.sql.ast.expr;
import com.alibaba.druid.sql.SQLUtils;
import com.alibaba.druid.sql.ast.SQLExpr;
import com.alibaba.druid.sql.ast.SQLExprImpl;
import com.alibaba.druid.sql.ast.SQLName;
@@ -138,4 +139,18 @@ public class SQLPropertyExpr extends SQLExprImpl implements SQLName {
return false;
}
public String normalizedName() {
String ownerName;
if (owner instanceof SQLIdentifierExpr) {
ownerName = ((SQLIdentifierExpr) owner).normalizedName();
} else if (owner instanceof SQLPropertyExpr) {
ownerName = ((SQLPropertyExpr) owner).normalizedName();
} else {
ownerName = owner.toString();
}
return ownerName + '.' + SQLUtils.normalize(name);
}
}