use of com.alibaba.druid.sql.dialect.mysql.visitor.MySqlOutputVisitor in project druid by alibaba.
the class MysqlTest method output.
protected String output(List<SQLStatement> stmtList) {
StringBuilder out = new StringBuilder();
MySqlOutputVisitor visitor = new MySqlOutputVisitor(out);
for (SQLStatement stmt : stmtList) {
stmt.accept(visitor);
}
return out.toString();
}
use of com.alibaba.druid.sql.dialect.mysql.visitor.MySqlOutputVisitor in project druid by alibaba.
the class OnlineSQLTest method validate.
void validate(int id, String sql) throws Exception {
sql = sql.trim();
boolean sqlFlag = false;
String lowerSql = sql.toLowerCase();
if (lowerSql.startsWith("insert") || lowerSql.startsWith("select") || lowerSql.startsWith("upate") || lowerSql.startsWith("delete") || lowerSql.startsWith("create") || lowerSql.startsWith("drop")) {
sqlFlag = true;
}
if (!sqlFlag) {
update(id, sql, 2);
return;
}
MySqlStatementParser parser = new MySqlStatementParser(sql);
List<SQLStatement> statementList = parser.parseStatementList();
SQLStatement statemen = statementList.get(0);
Assert.assertEquals(1, statementList.size());
StringBuilder out = new StringBuilder();
MySqlOutputVisitor visitor = new MySqlOutputVisitor(out, true);
statemen.accept(visitor);
update(id, out.toString(), 1);
System.out.println(sql);
System.out.println(out.toString());
}
use of com.alibaba.druid.sql.dialect.mysql.visitor.MySqlOutputVisitor in project druid by alibaba.
the class NumberTest method output.
private String output(List<SQLStatement> stmtList) {
StringBuilder out = new StringBuilder();
for (SQLStatement stmt : stmtList) {
stmt.accept(new MySqlOutputVisitor(out));
out.append(";");
}
return out.toString();
}
use of com.alibaba.druid.sql.dialect.mysql.visitor.MySqlOutputVisitor in project druid by alibaba.
the class REPLACE_Syntax_Test method output.
private String output(List<SQLStatement> stmtList) {
StringBuilder out = new StringBuilder();
for (SQLStatement stmt : stmtList) {
stmt.accept(new MySqlOutputVisitor(out));
out.append(";");
}
return out.toString();
}
use of com.alibaba.druid.sql.dialect.mysql.visitor.MySqlOutputVisitor in project druid by alibaba.
the class SHOW_STATUS_Syntax_Test method output.
private String output(List<SQLStatement> stmtList) {
StringBuilder out = new StringBuilder();
for (SQLStatement stmt : stmtList) {
stmt.accept(new MySqlOutputVisitor(out));
out.append(";");
}
return out.toString();
}
Aggregations