use of com.alibaba.druid.sql.dialect.oracle.visitor.OracleParameterizedOutputVisitor in project druid by alibaba.
the class MySqlParameterizedOutputVisitorTest method validateOracle.
void validateOracle(String sql, String expect) {
OracleStatementParser parser = new OracleStatementParser(sql);
List<SQLStatement> statementList = parser.parseStatementList();
SQLStatement stmt = statementList.get(0);
Assert.assertEquals(1, statementList.size());
StringBuilder out = new StringBuilder();
OracleParameterizedOutputVisitor visitor = new OracleParameterizedOutputVisitor(out, false);
stmt.accept(visitor);
Assert.assertTrue(visitor.getReplaceCount() > 0);
Assert.assertEquals(expect, out.toString());
}
use of com.alibaba.druid.sql.dialect.oracle.visitor.OracleParameterizedOutputVisitor in project druid by alibaba.
the class MySqlParameterizedOutputVisitorTest2 method validateOracle.
void validateOracle(String sql, String expect) {
OracleStatementParser parser = new OracleStatementParser(sql);
List<SQLStatement> statementList = parser.parseStatementList();
SQLStatement stmt = statementList.get(0);
Assert.assertEquals(1, statementList.size());
StringBuilder out = new StringBuilder();
OracleParameterizedOutputVisitor visitor = new OracleParameterizedOutputVisitor(out, false);
stmt.accept(visitor);
Assert.assertEquals(expect, out.toString());
}
use of com.alibaba.druid.sql.dialect.oracle.visitor.OracleParameterizedOutputVisitor in project druid by alibaba.
the class OnlineSQLTest method validateOracle.
void validateOracle(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;
}
OracleStatementParser parser = new OracleStatementParser(sql);
List<SQLStatement> statementList = parser.parseStatementList();
SQLStatement statemen = statementList.get(0);
Assert.assertEquals(1, statementList.size());
StringBuilder out = new StringBuilder();
OracleParameterizedOutputVisitor visitor = new OracleParameterizedOutputVisitor(out);
statemen.accept(visitor);
update(id, out.toString(), 1);
System.out.println(sql);
System.out.println(out.toString());
}
Aggregations