use of com.alibaba.druid.sql.ast.statement.SQLSelectItem in project druid by alibaba.
the class SQLAnyExpr method computeDataType.
public SQLDataType computeDataType() {
if (subQuery == null) {
return null;
}
SQLSelectQueryBlock queryBlock = subQuery.getFirstQueryBlock();
if (queryBlock == null) {
return null;
}
List<SQLSelectItem> selectList = queryBlock.getSelectList();
if (selectList.size() == 1) {
return selectList.get(0).computeDataType();
}
return null;
}
use of com.alibaba.druid.sql.ast.statement.SQLSelectItem in project druid by alibaba.
the class SQLSomeExpr method computeDataType.
public SQLDataType computeDataType() {
if (subQuery == null) {
return null;
}
SQLSelectQueryBlock queryBlock = subQuery.getFirstQueryBlock();
if (queryBlock == null) {
return null;
}
List<SQLSelectItem> selectList = queryBlock.getSelectList();
if (selectList.size() == 1) {
return selectList.get(0).computeDataType();
}
return null;
}
use of com.alibaba.druid.sql.ast.statement.SQLSelectItem in project druid by alibaba.
the class MySqlSelectQueryBlock method accept0.
@Override
public void accept0(MySqlASTVisitor visitor) {
if (visitor.visit(this)) {
for (int i = 0; i < this.selectList.size(); i++) {
SQLSelectItem item = this.selectList.get(i);
if (item != null) {
item.accept(visitor);
}
}
if (this.from != null) {
this.from.accept(visitor);
}
if (this.into != null) {
this.into.accept(visitor);
}
if (this.where != null) {
this.where.accept(visitor);
}
if (this.startWith != null) {
this.startWith.accept(visitor);
}
if (this.connectBy != null) {
this.connectBy.accept(visitor);
}
if (this.groupBy != null) {
this.groupBy.accept(visitor);
}
if (this.windows != null) {
for (SQLWindow item : windows) {
item.accept(visitor);
}
}
if (this.orderBy != null) {
this.orderBy.accept(visitor);
}
if (this.distributeBy != null) {
for (int i = 0; i < distributeBy.size(); i++) {
SQLSelectOrderByItem item = distributeBy.get(i);
item.accept(visitor);
}
}
if (this.sortBy != null) {
for (int i = 0; i < sortBy.size(); i++) {
SQLSelectOrderByItem item = sortBy.get(i);
item.accept(visitor);
}
}
if (this.waitTime != null) {
this.waitTime.accept(visitor);
}
if (this.limit != null) {
this.limit.accept(visitor);
}
if (this.procedureName != null) {
this.procedureName.accept(visitor);
}
if (this.procedureArgumentList != null) {
for (SQLExpr item : procedureArgumentList) {
item.accept(visitor);
}
}
}
visitor.endVisit(this);
}
use of com.alibaba.druid.sql.ast.statement.SQLSelectItem in project druid by alibaba.
the class OrderByResolve method visit.
public boolean visit(SQLSelect x) {
SQLSelectQueryBlock queryBlock = x.getQueryBlock();
if (queryBlock == null) {
return super.visit(x);
}
if (x.getOrderBy() != null && queryBlock.isForUpdate() && queryBlock.getOrderBy() == null) {
queryBlock.setOrderBy(x.getOrderBy());
x.setOrderBy(null);
}
SQLOrderBy orderBy = queryBlock.getOrderBy();
if (orderBy == null) {
return super.visit(x);
}
if (!queryBlock.selectItemHasAllColumn(false)) {
List<SQLSelectOrderByItem> notContainsOrderBy = new ArrayList<SQLSelectOrderByItem>();
for (SQLSelectOrderByItem orderByItem : orderBy.getItems()) {
SQLExpr orderByExpr = orderByItem.getExpr();
if (orderByExpr instanceof SQLName) {
if (((SQLName) orderByExpr).hashCode64() == DBMS_RANDOM_VALUE) {
continue;
}
long hashCode64 = ((SQLName) orderByExpr).nameHashCode64();
SQLSelectItem selectItem = queryBlock.findSelectItem(hashCode64);
if (selectItem == null) {
queryBlock.addSelectItem(orderByExpr.clone());
}
}
}
if (notContainsOrderBy.size() > 0) {
for (SQLSelectOrderByItem orderByItem : notContainsOrderBy) {
queryBlock.addSelectItem(orderByItem.getExpr());
}
OracleSelectQueryBlock queryBlock1 = new OracleSelectQueryBlock();
queryBlock1.setFrom(queryBlock, "x");
x.setQuery(queryBlock1);
}
}
return super.visit(x);
}
use of com.alibaba.druid.sql.ast.statement.SQLSelectItem in project druid by alibaba.
the class SQLServerExprParser method parseSelectItem.
public SQLSelectItem parseSelectItem() {
SQLExpr expr;
if (lexer.token() == Token.IDENTIFIER) {
expr = new SQLIdentifierExpr(lexer.stringVal());
lexer.nextTokenComma();
if (lexer.token() != Token.COMMA) {
expr = this.primaryRest(expr);
expr = this.exprRest(expr);
}
} else {
expr = this.expr();
}
final String alias = as();
return new SQLSelectItem(expr, alias);
}
Aggregations