Skip to content

Commit 3ccca01

Browse files
committed
fixes #296
refactored getTableList method of TableNamesFinder
1 parent b877da0 commit 3ccca01

File tree

2 files changed

+307
-328
lines changed

2 files changed

+307
-328
lines changed

src/main/java/net/sf/jsqlparser/util/TablesNamesFinder.java

Lines changed: 9 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import java.util.List;
3939

4040
import net.sf.jsqlparser.statement.SetStatement;
41+
import net.sf.jsqlparser.statement.Statement;
4142
import net.sf.jsqlparser.statement.StatementVisitor;
4243
import net.sf.jsqlparser.statement.Statements;
4344
import net.sf.jsqlparser.statement.alter.Alter;
@@ -69,45 +70,9 @@ public class TablesNamesFinder implements SelectVisitor, FromItemVisitor, Expres
6970
* @param delete
7071
* @return
7172
*/
72-
public List<String> getTableList(Delete delete) {
73+
public List<String> getTableList(Statement statement) {
7374
init();
74-
delete.accept(this);
75-
return tables;
76-
}
77-
78-
/**
79-
* Main entry for this Tool class. A list of found tables is returned.
80-
*
81-
* @param insert
82-
* @return
83-
*/
84-
public List<String> getTableList(Insert insert) {
85-
init();
86-
insert.accept(this);
87-
return tables;
88-
}
89-
90-
/**
91-
* Main entry for this Tool class. A list of found tables is returned.
92-
*
93-
* @param replace
94-
* @return
95-
*/
96-
public List<String> getTableList(Replace replace) {
97-
init();
98-
replace.accept(this);
99-
return tables;
100-
}
101-
102-
/**
103-
* Main entry for this Tool class. A list of found tables is returned.
104-
*
105-
* @param select
106-
* @return
107-
*/
108-
public List<String> getTableList(Select select) {
109-
init();
110-
select.accept(this);
75+
statement.accept(this);
11176
return tables;
11277
}
11378

@@ -127,17 +92,6 @@ public void visit(Select select) {
12792
* @param update
12893
* @return
12994
*/
130-
public List<String> getTableList(Update update) {
131-
init();
132-
update.accept(this);
133-
return tables;
134-
}
135-
136-
public List<String> getTableList(CreateTable create) {
137-
init();
138-
create.accept(this);
139-
return tables;
140-
}
14195

14296
public List<String> getTableList(Expression expr) {
14397
init();
@@ -642,7 +596,12 @@ public void visit(HexValue hexValue) {
642596

643597
@Override
644598
public void visit(Merge merge) {
645-
throw new UnsupportedOperationException(NOT_SUPPORTED_YET);
599+
tables.add(merge.getTable().getName());
600+
if (merge.getUsingTable() != null) {
601+
merge.getUsingTable().accept(this);
602+
} else if (merge.getUsingSelect() != null) {
603+
merge.getUsingSelect().accept((FromItemVisitor) this);
604+
}
646605
}
647606

648607
@Override

0 commit comments

Comments
 (0)