mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
Merge remote-tracking branch 'upstream/master'
This commit is contained in:
@@ -23,6 +23,7 @@ public class SQLSelectItem extends SQLObjectImpl {
|
||||
|
||||
private SQLExpr expr;
|
||||
private String alias;
|
||||
private boolean connectByRoot = false;
|
||||
|
||||
public SQLSelectItem(){
|
||||
|
||||
@@ -40,6 +41,16 @@ public class SQLSelectItem extends SQLObjectImpl {
|
||||
expr.setParent(this);
|
||||
}
|
||||
}
|
||||
|
||||
public SQLSelectItem(SQLExpr expr, String alias, boolean connectByRoot){
|
||||
this.connectByRoot = connectByRoot;
|
||||
this.expr = expr;
|
||||
this.alias = alias;
|
||||
|
||||
if (expr != null) {
|
||||
expr.setParent(this);
|
||||
}
|
||||
}
|
||||
|
||||
public SQLExpr getExpr() {
|
||||
return this.expr;
|
||||
@@ -61,6 +72,9 @@ public class SQLSelectItem extends SQLObjectImpl {
|
||||
}
|
||||
|
||||
public void output(StringBuffer buf) {
|
||||
if(this.connectByRoot) {
|
||||
buf.append(" CONNECT_BY_ROOT ");
|
||||
}
|
||||
this.expr.output(buf);
|
||||
if ((this.alias != null) && (this.alias.length() != 0)) {
|
||||
buf.append(" AS ");
|
||||
@@ -99,4 +113,12 @@ public class SQLSelectItem extends SQLObjectImpl {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isConnectByRoot() {
|
||||
return connectByRoot;
|
||||
}
|
||||
|
||||
public void setConnectByRoot(boolean connectByRoot) {
|
||||
this.connectByRoot = connectByRoot;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -306,6 +306,7 @@ public class SQLExprParser extends SQLParser {
|
||||
case EXCLUSIVE:
|
||||
case MODE:
|
||||
case ADVISE:
|
||||
case VIEW:
|
||||
sqlExpr = new SQLIdentifierExpr(lexer.stringVal());
|
||||
lexer.nextToken();
|
||||
break;
|
||||
|
||||
@@ -284,7 +284,12 @@ public class SQLSelectParser extends SQLParser {
|
||||
|
||||
protected SQLSelectItem parseSelectItem() {
|
||||
SQLExpr expr;
|
||||
boolean connectByRoot = false;
|
||||
if (lexer.token() == Token.IDENTIFIER) {
|
||||
if (identifierEquals("CONNECT_BY_ROOT")) {
|
||||
connectByRoot = true;
|
||||
lexer.nextToken();
|
||||
}
|
||||
expr = new SQLIdentifierExpr(lexer.stringVal());
|
||||
lexer.nextTokenComma();
|
||||
|
||||
@@ -297,7 +302,7 @@ public class SQLSelectParser extends SQLParser {
|
||||
}
|
||||
final String alias = as();
|
||||
|
||||
return new SQLSelectItem(expr, alias);
|
||||
return new SQLSelectItem(expr, alias, connectByRoot);
|
||||
}
|
||||
|
||||
public void parseFrom(SQLSelectQueryBlock queryBlock) {
|
||||
|
||||
@@ -697,6 +697,9 @@ public class SQLASTOutputVisitor extends SQLASTVisitorAdapter implements Printab
|
||||
}
|
||||
|
||||
public boolean visit(SQLSelectItem x) {
|
||||
if(x.isConnectByRoot()) {
|
||||
print("CONNECT_BY_ROOT ");
|
||||
}
|
||||
x.getExpr().accept(this);
|
||||
|
||||
if ((x.getAlias() != null) && (x.getAlias().length() > 0)) {
|
||||
|
||||
Reference in New Issue
Block a user