datasource-proxy
datasource-proxy copied to clipboard
Recursive CTE not recognized as SELECT
Recursive CTE are categoried as QueryType.OTHER instead of QueryType.SELECT by QueryUtils. Reproducer
class QueryUtilsTests {
@Test
void getQueryType() {
String sql = "WITH RECURSIVE t(n, level_num) AS (SELECT next value for SEQ_PARENT_ID as n, 1 as level_num UNION ALL SELECT next value for SEQ_PARENT_ID as n, level_num + 1 as level_num FROM t WHERE level_num < ?) SELECT n FROM t";
QueryType queryType = QueryUtils.getQueryType(sql);
assertSame(QueryType.SELECT, queryType);
}
}
Hi @marschall,
Thanks for the report.
Admittedly, the current QueryUtils.getQueryType is flawed.
I do not intend to provide a full query parser to detect the type, but at least the logic needs to be replaceable by the user.
I'll extract the logic to an interface based strategy and allow users to provide own query type detector.