Skip to content

Commit 96737b9

Browse files
committed
Merge origin/master
2 parents e82fd95 + 333c4a9 commit 96737b9

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/main/java/net/sf/jsqlparser/statement/select/SubJoin.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,11 @@ public String toString() {
6565
StringBuilder sb = new StringBuilder();
6666
sb.append("(").append(left);
6767
for (Join j : joinList) {
68-
sb.append(" ").append(j);
68+
if (j.isSimple()) {
69+
sb.append(", ").append(j);
70+
} else {
71+
sb.append(" ").append(j);
72+
}
6973
}
7074

7175
sb.append(")").append((alias != null) ? (" " + alias.toString()) : "").append((pivot != null) ? " " + pivot : "");

src/test/java/net/sf/jsqlparser/statement/select/SelectTest.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2009,6 +2009,12 @@ public void testWithStatement() throws JSQLParserException {
20092009
assertSqlCanBeParsedAndDeparsed(stmt);
20102010
}
20112011

2012+
@Test
2013+
public void testSubjoinWithJoins() throws JSQLParserException {
2014+
String stmt = "SELECT COUNT(DISTINCT `tbl1`.`id`) FROM (`tbl1`, `tbl2`, `tbl3`)";
2015+
assertSqlCanBeParsedAndDeparsed(stmt);
2016+
}
2017+
20122018
@Test
20132019
public void testWithUnionProblem() throws JSQLParserException {
20142020
String stmt = "WITH test AS ((SELECT mslink FROM tablea) UNION (SELECT mslink FROM tableb)) SELECT * FROM tablea WHERE mslink IN (SELECT mslink FROM test)";

0 commit comments

Comments
 (0)