修正输出格式

git-svn-id: http://code.alibabatech.com/svn/druid/trunk@163 b9813039-fb51-4c41-a8b9-e21c2acb5095
This commit is contained in:
wenshao
2011-05-20 17:23:04 +00:00
parent a4044e8e96
commit 511edb5b63
12 changed files with 66 additions and 22 deletions
@@ -120,7 +120,7 @@ public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTV
print("SQL_CALC_FOUND_ROWS ");
}
printAndAccept(select.getSelectList(), ", ");
printSelectList(select.getSelectList());
if (select.getOutFile() != null) {
println();
@@ -646,7 +646,7 @@ public class OracleOutputVisitor extends SQLASTOutputVisitor implements OracleAS
print("*/ ");
}
printAndAccept(select.getSelectList(), ", ");
printSelectList(select.getSelectList());
println();
print("FROM ");
@@ -137,11 +137,28 @@ public class SQLASTOutputVisitor extends SQLASTVisitorAdapter {
}
}
protected void printSelectList(List<SQLSelectItem> selectList) {
incrementIndent();
for (int i = 0, size = selectList.size(); i < size; ++i) {
if (i != 0) {
if (i % 5 == 0) {
println();
}
print(", ");
}
selectList.get(i).accept(this);
}
decrementIndent();
}
protected void printlnAndAccept(List<? extends SQLObject> nodes, String seperator) {
for (int i = 0, size = nodes.size(); i < size; ++i) {
if (i != 0) {
println(seperator);
}
((SQLObject) nodes.get(i)).accept(this);
}
}
@@ -424,7 +441,7 @@ public class SQLASTOutputVisitor extends SQLASTVisitorAdapter {
print("UNIQUE ");
}
printAndAccept(select.getSelectList(), ", ");
printSelectList(select.getSelectList());
if (select.getFrom() != null) {
println();
@@ -806,16 +823,16 @@ public class SQLASTOutputVisitor extends SQLASTVisitorAdapter {
return false;
}
@Override
public boolean visit(SQLListExpr x) {
print("(");
printAndAccept(x.getItems(), ", ");
print(")");
return false;
}
@Override
public boolean visit(SQLSubqueryTableSource x) {
print("(");
@@ -823,7 +840,7 @@ public class SQLASTOutputVisitor extends SQLASTVisitorAdapter {
x.getSelect().accept(this);
decrementIndent();
print(")");
return false;
}
}