use of net.sf.jsqlparser.expression.OracleHint in project JSqlParser by JSQLParser.
the class TablesNamesFinderTest method testOracleHint.
@Test
public void testOracleHint() throws JSQLParserException {
String sql = "select --+ HINT\ncol2 from mytable";
Select select = (Select) CCJSqlParserUtil.parse(sql);
final OracleHint[] holder = new OracleHint[1];
TablesNamesFinder tablesNamesFinder = new TablesNamesFinder() {
@Override
public void visit(OracleHint hint) {
super.visit(hint);
holder[0] = hint;
}
};
tablesNamesFinder.getTableList(select);
assertNull(holder[0]);
}
use of net.sf.jsqlparser.expression.OracleHint in project JSqlParser by JSQLParser.
the class TestUtils method assertOracleHintExists.
public static void assertOracleHintExists(String sql, boolean assertDeparser, String... hints) throws JSQLParserException {
if (assertDeparser) {
assertSqlCanBeParsedAndDeparsed(sql, true);
}
Select stmt = (Select) CCJSqlParserUtil.parse(sql);
if (stmt.getSelectBody() instanceof PlainSelect) {
PlainSelect ps = (PlainSelect) stmt.getSelectBody();
OracleHint hint = ps.getOracleHint();
assertNotNull(hint);
assertEquals(hints[0], hint.getValue());
} else {
if (stmt.getSelectBody() instanceof SetOperationList) {
SetOperationList setop = (SetOperationList) stmt.getSelectBody();
for (int i = 0; i < setop.getSelects().size(); i++) {
PlainSelect pselect = (PlainSelect) setop.getSelects().get(i);
OracleHint hint = pselect.getOracleHint();
if (hints[i] == null) {
Assert.assertNull(hint);
} else {
assertNotNull(hint);
assertEquals(hints[i], hint.getValue());
}
}
}
}
}
Aggregations