Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recursive CTE not recognized as SELECT #76

Open
marschall opened this issue Oct 22, 2021 · 1 comment
Open

Recursive CTE not recognized as SELECT #76

marschall opened this issue Oct 22, 2021 · 1 comment

Comments

@marschall
Copy link
Contributor

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);
  }

}
@ttddyy
Copy link
Member

ttddyy commented Oct 26, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants