Skip to content

Commit 71d6523

Browse files
committed
fixes #1009
1 parent c03733b commit 71d6523

File tree

4 files changed

+27
-5
lines changed

4 files changed

+27
-5
lines changed

pom.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
<dependency>
4747
<groupId>org.assertj</groupId>
4848
<artifactId>assertj-core</artifactId>
49-
<version>3.11.1</version>
49+
<version>3.16.1</version>
5050
<scope>test</scope>
5151
</dependency>
5252
</dependencies>
@@ -246,6 +246,9 @@
246246
<groupId>org.apache.maven.plugins</groupId>
247247
<artifactId>maven-surefire-plugin</artifactId>
248248
<version>3.0.0-M4</version>
249+
<configuration>
250+
<trimStackTrace>false</trimStackTrace>
251+
</configuration>
249252
</plugin>
250253
</plugins>
251254
</build>

src/main/java/net/sf/jsqlparser/expression/ExpressionVisitorAdapter.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,10 @@ public void visit(InExpression expr) {
172172
}
173173
if (expr.getRightExpression() != null) {
174174
expr.getRightExpression().accept(this);
175-
} else {
175+
} else if (expr.getRightItemsList() != null) {
176176
expr.getRightItemsList().accept(this);
177+
} else {
178+
expr.getMultiExpressionList().accept(this);
177179
}
178180
}
179181

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,13 @@ public void visit(InExpression inExpression) {
269269
} else if (inExpression.getLeftItemsList() != null) {
270270
inExpression.getLeftItemsList().accept(this);
271271
}
272-
inExpression.getRightItemsList().accept(this);
272+
if (inExpression.getRightExpression() != null) {
273+
inExpression.getRightExpression().accept(this);
274+
} else if (inExpression.getRightItemsList() != null) {
275+
inExpression.getRightItemsList().accept(this);
276+
} else {
277+
inExpression.getMultiExpressionList().accept(this);
278+
}
273279
}
274280

275281
@Override

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

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,12 @@
3636
import java.io.StringReader;
3737
import java.util.Iterator;
3838
import java.util.List;
39-
39+
import static org.assertj.core.api.Assertions.assertThat;
4040
import static org.assertj.core.api.Assertions.assertThatThrownBy;
41-
import static org.junit.Assert.*;
41+
import static org.junit.Assert.assertEquals;
42+
import static org.junit.Assert.assertNull;
43+
import static org.junit.Assert.assertTrue;
44+
4245

4346
public class TablesNamesFinderTest {
4447

@@ -615,4 +618,12 @@ public void testAlterSequence_throwsException() throws JSQLParserException {
615618
assertThatThrownBy(() -> tablesNamesFinder.getTableList(stmt)).isInstanceOf(UnsupportedOperationException.class)
616619
.hasMessage("Finding tables from AlterSequence is not supported");
617620
}
621+
622+
@Test
623+
public void testNPEIssue1009() throws JSQLParserException {
624+
Statement stmt = CCJSqlParserUtil.parse(" SELECT * FROM (SELECT * FROM biz_fund_info WHERE tenant_code = ? AND ((ta_code, manager_code) IN ((?, ?)) OR department_type IN (?)))");
625+
TablesNamesFinder tablesNamesFinder = new TablesNamesFinder();
626+
627+
assertThat(tablesNamesFinder.getTableList(stmt)).containsExactly("biz_fund_info");
628+
}
618629
}

0 commit comments

Comments
 (0)