Skip to content

Commit b877da0

Browse files
committed
fixes #295
1 parent c1d0b2f commit b877da0

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

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

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,8 @@ public class TablesNamesFinder implements SelectVisitor, FromItemVisitor, Expres
5858
private static final String NOT_SUPPORTED_YET = "Not supported yet.";
5959
private List<String> tables;
6060
/**
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.
61+
* There are special names, that are not table names but are parsed as tables. These names are
62+
* collected here and are not included in the tables - names anymore.
6463
*/
6564
private List<String> otherItemNames;
6665

@@ -246,7 +245,11 @@ public void visit(GreaterThanEquals greaterThanEquals) {
246245

247246
@Override
248247
public void visit(InExpression inExpression) {
249-
inExpression.getLeftExpression().accept(this);
248+
if (inExpression.getLeftExpression() != null) {
249+
inExpression.getLeftExpression().accept(this);
250+
} else if (inExpression.getLeftItemsList() != null) {
251+
inExpression.getLeftItemsList().accept(this);
252+
}
250253
inExpression.getRightItemsList().accept(this);
251254
}
252255

@@ -661,6 +664,6 @@ public void visit(TimeKeyExpression timeKeyExpression) {
661664

662665
@Override
663666
public void visit(DateTimeLiteralExpression literal) {
664-
667+
665668
}
666669
}

src/test/java/net/sf/jsqlparser/util/TablesNamesFinderTest.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,4 +374,15 @@ public void testGetTableListIssue284() throws Exception {
374374
assertTrue(tableList.contains("DUAL"));
375375
assertTrue(tableList.contains("TEST1"));
376376
}
377+
378+
@Test
379+
public void testUpdateGetTableListIssue295() throws JSQLParserException {
380+
Update statement = (Update) CCJSqlParserUtil.parse("UPDATE component SET col = 0 WHERE (component_id,ver_num) IN (SELECT component_id,ver_num FROM component_temp)");
381+
TablesNamesFinder tablesNamesFinder = new TablesNamesFinder();
382+
List<String> tableList = tablesNamesFinder.getTableList(statement);
383+
assertEquals(2, tableList.size());
384+
assertTrue(tableList.contains("component"));
385+
assertTrue(tableList.contains("component_temp"));
386+
387+
}
377388
}

0 commit comments

Comments
 (0)