mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
add feature support for issue #1815
This commit is contained in:
@@ -42,7 +42,14 @@ import com.alibaba.druid.sql.dialect.oracle.ast.stmt.OracleForStatement;
|
||||
import com.alibaba.druid.util.JdbcConstants;
|
||||
import com.alibaba.druid.util.JdbcUtils;
|
||||
|
||||
import static com.alibaba.druid.util.Utils.getBoolean;
|
||||
|
||||
public class SQLASTOutputVisitor extends SQLASTVisitorAdapter implements ParameterizedVisitor, PrintableVisitor {
|
||||
public static Boolean defaultPrintStatementAfterSemi;
|
||||
|
||||
static {
|
||||
defaultPrintStatementAfterSemi = getBoolean(System.getProperties(), "druid.sql.output.printStatementAfterSemi"); // compatible for early versions
|
||||
}
|
||||
|
||||
protected final Appendable appender;
|
||||
private String indent = "\t";
|
||||
@@ -74,6 +81,8 @@ public class SQLASTOutputVisitor extends SQLASTVisitorAdapter implements Paramet
|
||||
|
||||
protected boolean desensitize = false;
|
||||
|
||||
protected Boolean printStatementAfterSemi = defaultPrintStatementAfterSemi;
|
||||
|
||||
public SQLASTOutputVisitor(Appendable appender){
|
||||
this.appender = appender;
|
||||
}
|
||||
@@ -4543,7 +4552,10 @@ public class SQLASTOutputVisitor extends SQLASTVisitorAdapter implements Paramet
|
||||
public void postVisit(SQLObject x) {
|
||||
if (x instanceof SQLStatement) {
|
||||
SQLStatement stmt = (SQLStatement) x;
|
||||
if (stmt.isAfterSemi()) {
|
||||
boolean printSemi = printStatementAfterSemi == null
|
||||
? stmt.isAfterSemi()
|
||||
: printStatementAfterSemi.booleanValue();
|
||||
if (printSemi) {
|
||||
print(';');
|
||||
}
|
||||
}
|
||||
@@ -4680,4 +4692,12 @@ public class SQLASTOutputVisitor extends SQLASTVisitorAdapter implements Paramet
|
||||
x.getQuery().accept(this);
|
||||
return false;
|
||||
}
|
||||
|
||||
public Boolean getPrintStatementAfterSemi() {
|
||||
return printStatementAfterSemi;
|
||||
}
|
||||
|
||||
public void setPrintStatementAfterSemi(Boolean printStatementAfterSemi) {
|
||||
this.printStatementAfterSemi = printStatementAfterSemi;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user