-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
[BUG] JSQLParser 4.5/4.6 : RDBMS : extension field exception #1766
-
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
Beta Was this translation helpful? Give feedback.
All reactions
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); }
Replies: 4 comments
-
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:
Beta Was this translation helpful? Give feedback.
All reactions
-
Hello, I need to add field values to existing SQL statements. May I know how to proceed? Thank you
Beta Was this translation helpful? Give feedback.
All reactions
-
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); }
Beta Was this translation helpful? Give feedback.
All reactions
-
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); }
Beta Was this translation helpful? Give feedback.