File tree Expand file tree Collapse file tree 2 files changed +21
-2
lines changed
main/java/net/sf/jsqlparser/expression
test/java/net/sf/jsqlparser/expression Expand file tree Collapse file tree 2 files changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -213,8 +213,10 @@ public void visit(Column column) {
213
213
@ Override
214
214
public void visit (SubSelect subSelect ) {
215
215
if (selectVisitor != null ) {
216
- for (WithItem item : subSelect .getWithItemsList ()) {
217
- item .accept (selectVisitor );
216
+ if (subSelect .getWithItemsList () != null ) {
217
+ for (WithItem item : subSelect .getWithItemsList ()) {
218
+ item .accept (selectVisitor );
219
+ }
218
220
}
219
221
subSelect .getSelectBody ().accept (selectVisitor );
220
222
}
Original file line number Diff line number Diff line change 27
27
import net .sf .jsqlparser .schema .Column ;
28
28
import net .sf .jsqlparser .statement .select .PlainSelect ;
29
29
import net .sf .jsqlparser .statement .select .Select ;
30
+ import net .sf .jsqlparser .statement .select .SelectVisitorAdapter ;
30
31
import org .junit .After ;
31
32
import org .junit .AfterClass ;
32
33
import static org .junit .Assert .assertNotNull ;
33
34
import static org .junit .Assert .assertNull ;
34
35
import static org .junit .Assert .assertTrue ;
35
36
import static org .junit .Assert .assertFalse ;
36
37
import static org .junit .Assert .assertEquals ;
38
+ import static org .junit .Assert .fail ;
37
39
import org .junit .Before ;
38
40
import org .junit .BeforeClass ;
39
41
import org .junit .Test ;
@@ -169,4 +171,19 @@ public void visit(Column column) {
169
171
assertEquals (1 , columnList .size ());
170
172
assertEquals ("bar" , columnList .get (0 ));
171
173
}
174
+
175
+ @ Test
176
+ public void testSubSelectExpressionProblem () throws JSQLParserException {
177
+ Select select = (Select ) CCJSqlParserUtil .parse ( "SELECT * FROM t1 WHERE EXISTS (SELECT * FROM t2 WHERE t2.col2 = t1.col1)" );
178
+ PlainSelect plainSelect = (PlainSelect ) select .getSelectBody ();
179
+ Expression where = plainSelect .getWhere ();
180
+ ExpressionVisitorAdapter adapter = new ExpressionVisitorAdapter ();
181
+ adapter .setSelectVisitor (new SelectVisitorAdapter ());
182
+ try {
183
+ where .accept (adapter );
184
+ } catch (NullPointerException npe ){
185
+ fail ();
186
+ }
187
+ }
188
+
172
189
}
You can’t perform that action at this time.
0 commit comments