Skip to content

Commit 8e7ba38

Browse files
committed
fixes #284
1 parent 04fc3aa commit 8e7ba38

File tree

2 files changed

+23
-10
lines changed

2 files changed

+23
-10
lines changed

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

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
public class TablesNamesFinder implements SelectVisitor, FromItemVisitor, ExpressionVisitor, ItemsListVisitor, SelectItemVisitor, StatementVisitor {
5757

5858
private static final String NOT_SUPPORTED_YET = "Not supported yet.";
59-
private List<String> tables;
59+
private List<String> tables;
6060
/**
6161
* There are special names, that are not table names but are parsed as
6262
* tables. These names are collected here and are not included in the tables
@@ -228,6 +228,10 @@ public void visit(EqualsTo equalsTo) {
228228

229229
@Override
230230
public void visit(Function function) {
231+
ExpressionList exprList = function.getParameters();
232+
if (exprList != null) {
233+
visit(exprList);
234+
}
231235
}
232236

233237
@Override
@@ -326,7 +330,6 @@ public void visit(ExpressionList expressionList) {
326330
for (Expression expression : expressionList.getExpressions()) {
327331
expression.accept(this);
328332
}
329-
330333
}
331334

332335
@Override
@@ -576,17 +579,17 @@ public void visit(Replace replace) {
576579

577580
@Override
578581
public void visit(Drop drop) {
579-
throw new UnsupportedOperationException(NOT_SUPPORTED_YET);
582+
throw new UnsupportedOperationException(NOT_SUPPORTED_YET);
580583
}
581584

582585
@Override
583586
public void visit(Truncate truncate) {
584-
throw new UnsupportedOperationException(NOT_SUPPORTED_YET);
587+
throw new UnsupportedOperationException(NOT_SUPPORTED_YET);
585588
}
586589

587590
@Override
588591
public void visit(CreateIndex createIndex) {
589-
throw new UnsupportedOperationException(NOT_SUPPORTED_YET);
592+
throw new UnsupportedOperationException(NOT_SUPPORTED_YET);
590593
}
591594

592595
@Override
@@ -599,12 +602,12 @@ public void visit(CreateTable create) {
599602

600603
@Override
601604
public void visit(CreateView createView) {
602-
throw new UnsupportedOperationException(NOT_SUPPORTED_YET);
605+
throw new UnsupportedOperationException(NOT_SUPPORTED_YET);
603606
}
604607

605608
@Override
606609
public void visit(Alter alter) {
607-
throw new UnsupportedOperationException(NOT_SUPPORTED_YET);
610+
throw new UnsupportedOperationException(NOT_SUPPORTED_YET);
608611
}
609612

610613
@Override
@@ -619,7 +622,7 @@ public void visit(Execute execute) {
619622

620623
@Override
621624
public void visit(SetStatement set) {
622-
throw new UnsupportedOperationException(NOT_SUPPORTED_YET);
625+
throw new UnsupportedOperationException(NOT_SUPPORTED_YET);
623626
}
624627

625628
@Override
@@ -649,7 +652,7 @@ public void visit(TableFunction valuesList) {
649652

650653
@Override
651654
public void visit(AlterView alterView) {
652-
throw new UnsupportedOperationException(NOT_SUPPORTED_YET);
655+
throw new UnsupportedOperationException(NOT_SUPPORTED_YET);
653656
}
654657

655658
@Override

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,5 +363,15 @@ public void testGetTableListIssue194() throws Exception {
363363
List<String> tableList = tablesNamesFinder.getTableList(selectStatement);
364364
assertEquals(0, tableList.size());
365365
}
366-
366+
367+
@Test
368+
public void testGetTableListIssue284() throws Exception {
369+
String sql = "SELECT NVL( (SELECT 1 FROM DUAL), 1) AS A FROM TEST1";
370+
Select selectStatement = (Select) CCJSqlParserUtil.parse(sql);
371+
TablesNamesFinder tablesNamesFinder = new TablesNamesFinder();
372+
List<String> tableList = tablesNamesFinder.getTableList(selectStatement);
373+
assertEquals(2, tableList.size());
374+
assertTrue(tableList.contains("DUAL"));
375+
assertTrue(tableList.contains("TEST1"));
376+
}
367377
}

0 commit comments

Comments
 (0)