use of org.jdbi.v3.core.internal.SqlScriptParser in project jdbi by jdbi.
the class Script method splitToStatements.
private List<String> splitToStatements(String script) {
final List<String> statements = new ArrayList<>();
String lastStatement = new SqlScriptParser((t, sb) -> {
addStatement(sb.toString(), statements);
sb.setLength(0);
}).parse(new ANTLRStringStream(script));
addStatement(lastStatement, statements);
return statements;
}
use of org.jdbi.v3.core.internal.SqlScriptParser in project irontest by zheng-wang.
the class IronTestUtils method getStatements.
/**
* Parse the sqlRequest to get SQL statements, trimmed and without comments.
* @param sqlRequest
* @return
*/
public static List<String> getStatements(String sqlRequest) {
final List<String> statements = new ArrayList<>();
String lastStatement = new SqlScriptParser((t, sb) -> {
statements.add(sb.toString().trim());
sb.setLength(0);
}).parse(new ANTLRStringStream(sqlRequest));
statements.add(lastStatement.trim());
// remove all empty statements
statements.removeAll(Collections.singleton(""));
return statements;
}
Aggregations