Skip to content

[BUG] JSQLParser Version 4.7 : WithItems moved inside Select  #1895

Description

@serhiizapalskyi

Failing SQL Feature:

I'm not sure is it a bug or feature, but unfortunately it breaks our current behavior. After migration from 4.5 to 4.7 the query WITH events as (select * from table1) select t1 from events is parsed with select body including WithItems. In previous versions Select.getSelectBody() was returning select without WithItems.

So Select.getSelectBody (I know it is deprecated) will result different in 4.5 and 4.7:
4.5: select t1 from events
4.7 WITH events as (select * from table1) select t1 from events

I see that Select structure was changed:
In 4.5 there was separately selectBody and withItems
In 4.7 withItems are included into select

The question:

Can I get select without WithItems (like it was in 4.5)?

SQL Example:

  • Simplified Query Example, focusing on the failing feature
          WITH events as (
                 select * from table1
           ) 
           select t1 
           from  events
    

Software Information:

  • JSqlParser version 4.7

Tips:

The same query has different structure in different versions of parser

4.5 Structure:

Screenshot 2023-11-22 at 13 44 45

4.7 Structure:

image

Thanks in advance,
Regards, Serhii Zapalskyi

Activity

  1. manticore-projects commented on Nov 26, 2023

    @manticore-projects
    Contributor

    Greetings!

    Thank you for your question. Although I have read it carefully three time and I am still not sure what your are asking for.
    With JSQLParser-4.7 your AST will look like shown below. Your can try this by yourself online and interactively.

    Are you trying to to eliminate the With clause from the PlainSelect? If so, then why not just ignore the PlainSelect's property withItemsList or set it to NULL (in case your are rewriting).

    image

  2. manticore-projects commented on Nov 26, 2023

    @manticore-projects
    Contributor

    Here is the Java API for PlainSelect showing how to modify the withItemsList property:
    https://manticore-projects.com/JSQLParser/javadoc_stable.html#select

  3. locked and limited conversation to collaborators on Nov 26, 2023
  4. converted this issue into a discussion #1896 on Nov 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions