Skip to content

Commit 04d2b65

Browse files
committed
Merge origin/master
2 parents 84a8836 + 3ccca01 commit 04d2b65

File tree

2 files changed

+322
-329
lines changed

2 files changed

+322
-329
lines changed

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

Lines changed: 17 additions & 55 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;
@@ -58,9 +59,8 @@ public class TablesNamesFinder implements SelectVisitor, FromItemVisitor, Expres
5859
private static final String NOT_SUPPORTED_YET = "Not supported yet.";
5960
private List<String> tables;
6061
/**
61-
* There are special names, that are not table names but are parsed as
62-
* tables. These names are collected here and are not included in the tables
63-
* - names anymore.
62+
* There are special names, that are not table names but are parsed as tables. These names are
63+
* collected here and are not included in the tables - names anymore.
6464
*/
6565
private List<String> otherItemNames;
6666

@@ -70,45 +70,9 @@ public class TablesNamesFinder implements SelectVisitor, FromItemVisitor, Expres
7070
* @param delete
7171
* @return
7272
*/
73-
public List<String> getTableList(Delete delete) {
73+
public List<String> getTableList(Statement statement) {
7474
init();
75-
delete.accept(this);
76-
return tables;
77-
}
78-
79-
/**
80-
* Main entry for this Tool class. A list of found tables is returned.
81-
*
82-
* @param insert
83-
* @return
84-
*/
85-
public List<String> getTableList(Insert insert) {
86-
init();
87-
insert.accept(this);
88-
return tables;
89-
}
90-
91-
/**
92-
* Main entry for this Tool class. A list of found tables is returned.
93-
*
94-
* @param replace
95-
* @return
96-
*/
97-
public List<String> getTableList(Replace replace) {
98-
init();
99-
replace.accept(this);
100-
return tables;
101-
}
102-
103-
/**
104-
* Main entry for this Tool class. A list of found tables is returned.
105-
*
106-
* @param select
107-
* @return
108-
*/
109-
public List<String> getTableList(Select select) {
110-
init();
111-
select.accept(this);
75+
statement.accept(this);
11276
return tables;
11377
}
11478

@@ -128,17 +92,6 @@ public void visit(Select select) {
12892
* @param update
12993
* @return
13094
*/
131-
public List<String> getTableList(Update update) {
132-
init();
133-
update.accept(this);
134-
return tables;
135-
}
136-
137-
public List<String> getTableList(CreateTable create) {
138-
init();
139-
create.accept(this);
140-
return tables;
141-
}
14295

14396
public List<String> getTableList(Expression expr) {
14497
init();
@@ -246,7 +199,11 @@ public void visit(GreaterThanEquals greaterThanEquals) {
246199

247200
@Override
248201
public void visit(InExpression inExpression) {
249-
inExpression.getLeftExpression().accept(this);
202+
if (inExpression.getLeftExpression() != null) {
203+
inExpression.getLeftExpression().accept(this);
204+
} else if (inExpression.getLeftItemsList() != null) {
205+
inExpression.getLeftItemsList().accept(this);
206+
}
250207
inExpression.getRightItemsList().accept(this);
251208
}
252209

@@ -639,7 +596,12 @@ public void visit(HexValue hexValue) {
639596

640597
@Override
641598
public void visit(Merge merge) {
642-
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+
}
643605
}
644606

645607
@Override
@@ -661,6 +623,6 @@ public void visit(TimeKeyExpression timeKeyExpression) {
661623

662624
@Override
663625
public void visit(DateTimeLiteralExpression literal) {
664-
626+
665627
}
666628
}

0 commit comments

Comments
 (0)