use of com.alibaba.cobar.parser.ast.fragment.OrderBy in project cobar by alibaba.
the class MySQLOutputASTVisitor method visit.
@Override
public void visit(DMLUpdateStatement node) {
appendable.append("UPDATE ");
if (node.isLowPriority()) {
appendable.append("LOW_PRIORITY ");
}
if (node.isIgnore()) {
appendable.append("IGNORE ");
}
node.getTableRefs().accept(this);
appendable.append(" SET ");
boolean isFst = true;
for (Pair<Identifier, Expression> p : node.getValues()) {
if (isFst)
isFst = false;
else
appendable.append(", ");
p.getKey().accept(this);
appendable.append(" = ");
p.getValue().accept(this);
}
Expression where = node.getWhere();
if (where != null) {
appendable.append(" WHERE ");
where.accept(this);
}
OrderBy order = node.getOrderBy();
if (order != null) {
appendable.append(' ');
order.accept(this);
}
Limit limit = node.getLimit();
if (limit != null) {
appendable.append(' ');
limit.accept(this);
}
}
use of com.alibaba.cobar.parser.ast.fragment.OrderBy in project cobar by alibaba.
the class MySQLOutputASTVisitor method visit.
@Override
public void visit(DMLSelectUnionStatement node) {
List<DMLSelectStatement> list = node.getSelectStmtList();
if (list == null || list.isEmpty()) {
throw new IllegalArgumentException("SELECT UNION must have at least one SELECT");
}
final int fstDist = node.getFirstDistinctIndex();
int i = 0;
for (DMLSelectStatement select : list) {
if (i > 0) {
appendable.append(" UNION ");
if (i > fstDist) {
appendable.append("ALL ");
}
}
appendable.append('(');
select.accept(this);
appendable.append(')');
++i;
}
OrderBy order = node.getOrderBy();
if (order != null) {
appendable.append(' ');
order.accept(this);
}
Limit limit = node.getLimit();
if (limit != null) {
appendable.append(' ');
limit.accept(this);
}
}
Aggregations