use of net.sf.jsqlparser.parser.StringProvider in project herddb by diennea.
the class JSQLParserPlanner method parseStatement.
private net.sf.jsqlparser.statement.Statement parseStatement(String query) throws StatementExecutionException {
net.sf.jsqlparser.statement.Statement stmt;
CCJSqlParser parser = new CCJSqlParser(new StringProvider(query));
// parser.setErrorRecovery(true);
try {
return parser.Statement();
} catch (ParseException err) {
throw new StatementExecutionException("unable to parse query " + query, err);
}
}
use of net.sf.jsqlparser.parser.StringProvider in project JSqlParser by JSQLParser.
the class StatementsTest method testStatementsErrorRecovery3.
@Test
public void testStatementsErrorRecovery3() throws JSQLParserException, ParseException {
String sqls = "select * from mytable; select * from;select * from mytable2";
CCJSqlParser parser = new CCJSqlParser(new StringProvider(sqls));
parser.setErrorRecovery(true);
Statements parseStatements = parser.Statements();
assertEquals(2, parseStatements.getStatements().size());
assertTrue(parseStatements.getStatements().get(0) instanceof Select);
assertNull(parseStatements.getStatements().get(1));
assertEquals(2, parser.getParseErrors().size());
}
use of net.sf.jsqlparser.parser.StringProvider in project JSqlParser by JSQLParser.
the class StatementsTest method testStatementsErrorRecovery2.
@Test
public void testStatementsErrorRecovery2() throws JSQLParserException, ParseException {
String sqls = "select * from1 table;";
CCJSqlParser parser = new CCJSqlParser(new StringProvider(sqls));
parser.setErrorRecovery(true);
Statements parseStatements = parser.Statements();
assertEquals(1, parseStatements.getStatements().size());
assertTrue(parseStatements.getStatements().get(0) instanceof Select);
assertEquals(1, parser.getParseErrors().size());
}
use of net.sf.jsqlparser.parser.StringProvider in project JSqlParser by JSQLParser.
the class StatementsTest method testStatementsErrorRecovery.
@Test
public void testStatementsErrorRecovery() throws JSQLParserException, ParseException {
String sqls = "select * from mytable; select * from;";
CCJSqlParser parser = new CCJSqlParser(new StringProvider(sqls));
parser.setErrorRecovery(true);
Statements parseStatements = parser.Statements();
assertEquals(2, parseStatements.getStatements().size());
assertTrue(parseStatements.getStatements().get(0) instanceof Select);
assertNull(parseStatements.getStatements().get(1));
}
Aggregations