mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
improved oracle sql parser support fetch clause. issue #1448
This commit is contained in:
@@ -787,9 +787,31 @@ public class SQLASTOutputVisitor extends SQLASTVisitorAdapter implements Paramet
|
||||
x.getOrderBy().accept(this);
|
||||
}
|
||||
|
||||
printFetchFirst(x);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
protected void printFetchFirst(SQLSelectQueryBlock x) {
|
||||
if (x.getFirst() != null) {
|
||||
//order by 语句必须在FETCH FIRST ROWS ONLY之前
|
||||
SQLObject parent= x.getParent();
|
||||
if(parent instanceof SQLSelect) {
|
||||
SQLOrderBy orderBy = ((SQLSelect) parent).getOrderBy();
|
||||
if (orderBy!=null&&orderBy.getItems().size() > 0) {
|
||||
println();
|
||||
print0(ucase ? "ORDER BY " : "order by ");
|
||||
printAndAccept(orderBy.getItems(), ", ");
|
||||
((SQLSelect) parent).setOrderBy(null);
|
||||
}
|
||||
}
|
||||
println();
|
||||
print0(ucase ? "FETCH FIRST " : "fetch first ");
|
||||
x.getFirst().accept(this);
|
||||
print0(ucase ? " ROWS ONLY" : " rows only");
|
||||
}
|
||||
}
|
||||
|
||||
public boolean visit(SQLSelectItem x) {
|
||||
if (x.isConnectByRoot()) {
|
||||
print0(ucase ? "CONNECT_BY_ROOT " : "connect_by_root ");
|
||||
|
||||
Reference in New Issue
Block a user