File tree Expand file tree Collapse file tree 3 files changed +18
-6
lines changed
java/net/sf/jsqlparser/statement/merge
jjtree/net/sf/jsqlparser/parser
test/java/net/sf/jsqlparser/test/merge Expand file tree Collapse file tree 3 files changed +18
-6
lines changed Original file line number Diff line number Diff line change @@ -112,13 +112,13 @@ public String toString() {
112112 StringBuilder b = new StringBuilder ();
113113 b .append ("MERGE INTO " );
114114 b .append (table );
115- b .append (" USING ( " );
115+ b .append (" USING " );
116116 if (usingTable != null ) {
117117 b .append (usingTable .toString ());
118118 } else if (usingSelect != null ) {
119- b .append (usingSelect .toString ());
119+ b .append ("(" ). append ( usingSelect .toString ()). append ( ")" );
120120 }
121- b . append ( ")" );
121+
122122 if (usingAlias != null ) {
123123 b .append (usingAlias .toString ());
124124 }
Original file line number Diff line number Diff line change @@ -582,10 +582,10 @@ Statement Merge() : {
582582}
583583{
584584 <K_MERGE> <K_INTO> table=TableWithAlias() { merge.setTable(table); }
585- <K_USING> "("
585+ <K_USING>
586586 ( table=Table() { merge.setUsingTable(table); }
587- | select=SubSelect() { merge.setUsingSelect(select); } )
588- ")" [ alias = Alias() { merge.setUsingAlias(alias); } ] <K_ON>
587+ | "(" select=SubSelect() { merge.setUsingSelect(select); } ")" )
588+ [ alias = Alias() { merge.setUsingAlias(alias); } ] <K_ON>
589589 "(" condition = Condition() { merge.setOnCondition(condition); } ")"
590590
591591 [ LOOKAHEAD(2) update = MergeUpdateClause() { merge.setMergeUpdate(update); } ]
Original file line number Diff line number Diff line change @@ -50,4 +50,16 @@ public void testOracleMergeIntoStatement() throws JSQLParserException {
5050
5151 assertSqlCanBeParsedAndDeparsed (sql , true );
5252 }
53+
54+ @ Test
55+ public void testMergeIssue232 () throws JSQLParserException {
56+ String sql = "MERGE INTO xyz using dual " +
57+ "ON ( custom_id = ? ) " +
58+ "WHEN matched THEN " +
59+ "UPDATE SET abc = sysdate " +
60+ "WHEN NOT matched THEN " +
61+ "INSERT (custom_id) VALUES (?)" ;
62+
63+ assertSqlCanBeParsedAndDeparsed (sql , true );
64+ }
5365}
You can’t perform that action at this time.
0 commit comments