Skip to content

Commit 7feb3bc

Browse files
feat: better defaults for FromItemVisitorAdaptor
Signed-off-by: Andreas Reichel <[email protected]>
1 parent 296d032 commit 7feb3bc

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

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

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,24 @@
1212
import net.sf.jsqlparser.schema.Table;
1313
import net.sf.jsqlparser.statement.piped.FromQuery;
1414

15+
import java.util.ArrayList;
16+
1517
@SuppressWarnings({"PMD.UncommentedEmptyMethodBody"})
1618
public class FromItemVisitorAdapter<T> implements FromItemVisitor<T> {
1719

1820
@Override
1921
public <S> T visit(Table table, S context) {
20-
2122
return null;
2223
}
2324

2425
@Override
2526
public <S> T visit(ParenthesedSelect select, S context) {
26-
27-
return null;
27+
return select.getPlainSelect().getFromItem().accept(this, context);
2828
}
2929

3030
@Override
3131
public <S> T visit(LateralSubSelect lateralSubSelect, S context) {
32-
33-
return null;
32+
return lateralSubSelect.getPlainSelect().getFromItem().accept(this, context);
3433
}
3534

3635
@Override
@@ -41,36 +40,35 @@ public <S> T visit(TableFunction tableFunction, S context) {
4140

4241
@Override
4342
public <S> T visit(ParenthesedFromItem fromItem, S context) {
44-
45-
return null;
43+
return fromItem.getFromItem().accept(this, context);
4644
}
4745

4846
@Override
4947
public <S> T visit(Values values, S context) {
50-
5148
return null;
5249
}
5350

5451
@Override
5552
public <S> T visit(PlainSelect plainSelect, S context) {
56-
57-
return null;
53+
return plainSelect.getFromItem().accept(this, context);
5854
}
5955

6056
@Override
6157
public <S> T visit(SetOperationList setOperationList, S context) {
62-
63-
return null;
58+
ArrayList<T> results = new ArrayList<>();
59+
for (Select select : setOperationList.getSelects()) {
60+
results.add(select.accept(this, context));
61+
}
62+
return results.isEmpty() ? null : results.get(0);
6463
}
6564

6665
@Override
6766
public <S> T visit(TableStatement tableStatement, S context) {
68-
6967
return null;
7068
}
7169

7270
@Override
7371
public <S> T visit(FromQuery fromQuery, S context) {
74-
return null;
72+
return fromQuery.getFromItem().accept(this, context);
7573
}
7674
}

0 commit comments

Comments
 (0)