GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [BUG] JSQLParser 4.5/4.6 : RDBMS : extension field exception · Issue #1765 · JSQLParser/JSqlParser

[BUG] JSQLParser 4.5/4.6 : RDBMS : extension field exception #1765

New issue
Copy link
New issue
Copy link
Closed
Closed
[BUG] JSQLParser 4.5/4.6 : RDBMS : extension field exception#1765
Copy link

Description

@licai1210
licai1210
opened on Apr 17, 2023
Issue body actions

image

Hello, this issue is normal in 4.4, and there is an inaccurate issue with dynamically adding fields in the insert statement in 4.5/4.6. May I know how to solve it? Thank you

Activity

  1. manticore-projects commented on Apr 17, 2023

    @manticore-projects
    manticore-projects
    on Apr 17, 2023
    Contributor
    More actions

    Greetings.

    A lots of API has changed between 4.4 and 4.6 in order to streamline VALUES (..) statements.
    The easiest way to figure out the AST is using JSQLFormatter, which can visualize the Tree of Java Objects:

    image

    You can try it online here

  2. licai1210 commented on Apr 18, 2023

    @licai1210
    licai1210
    on Apr 18, 2023
    Author
    More actions

    Hello, I need to add field values to existing SQL statements. May I know how to proceed? Thank you

  3. manticore-projects commented on Apr 18, 2023

    @manticore-projects
    manticore-projects
    on Apr 18, 2023
    Contributor
    More actions

    Recommendation: Checkout PR #1754 which will allow for

        @Test
        void testIssue1765() {
            String sqlStr = "INSERT INTO mytable (col1)\n"
                            + "VALUES ( 1 )";
    
            Insert insert = new Insert()
                                .withTable( new Table("mytable") )
                                .withColumns( Arrays.asList(new Column("col1")) )
                                .withSelect( new Values().addExpressions(new LongValue(1)) );
    
            assertStatementCanBeDeparsedAs(insert, sqlStr,true);
        }
  4. manticore-projects commented on Apr 18, 2023

    @manticore-projects
    manticore-projects
    on Apr 18, 2023
    Contributor
    More actions

    If you use Release 4.6 then your code will look like this:

        @Test
        void testIssue1765() {
            String sqlStr = "INSERT INTO mytable (col1)\n"
                            + "VALUES ( 1 )";
    
            Select select = new Select()
                                    .withSelectBody( new ValuesStatement().addExpressions( new LongValue(1)) );
    
            Insert insert = new Insert()
                                    .withTable( new Table("mytable") )
                                    .withColumns( Arrays.asList(new Column("col1")) )
                                    .withSelect(  select );
    
            assertStatementCanBeDeparsedAs(insert, sqlStr,true);
        }
  5. manticore-projects
    converted this issue into a discussion #1766 on Apr 18, 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

      You are visitor 01402520 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.