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() {
112
112
StringBuilder b = new StringBuilder ();
113
113
b .append ("MERGE INTO " );
114
114
b .append (table );
115
- b .append (" USING ( " );
115
+ b .append (" USING " );
116
116
if (usingTable != null ) {
117
117
b .append (usingTable .toString ());
118
118
} else if (usingSelect != null ) {
119
- b .append (usingSelect .toString ());
119
+ b .append ("(" ). append ( usingSelect .toString ()). append ( ")" );
120
120
}
121
- b . append ( ")" );
121
+
122
122
if (usingAlias != null ) {
123
123
b .append (usingAlias .toString ());
124
124
}
Original file line number Diff line number Diff line change @@ -582,10 +582,10 @@ Statement Merge() : {
582
582
}
583
583
{
584
584
<K_MERGE> <K_INTO> table=TableWithAlias() { merge.setTable(table); }
585
- <K_USING> "("
585
+ <K_USING>
586
586
( 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>
589
589
"(" condition = Condition() { merge.setOnCondition(condition); } ")"
590
590
591
591
[ 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 {
50
50
51
51
assertSqlCanBeParsedAndDeparsed (sql , true );
52
52
}
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
+ }
53
65
}
You can’t perform that action at this time.
0 commit comments