Skip to content
Snippets Groups Projects
Commit 232bf9c9 authored by gmantele's avatar gmantele
Browse files

[ADQL] Fix a NullPointerException in SearchColumnOutsiteGroupByHandler.gotInto.

See the test case TestDBChecker.testClauseADQLWithNameNull() for more details.
parent 6ecd7240
No related branches found
No related tags found
No related merge requests found
......@@ -1306,13 +1306,13 @@ public class DBChecker implements QueryChecker {
* </p>
*
* @author Gr&eacute;gory Mantelet (ARI)
* @version 1.4 (04/2017)
* @version 1.4 (05/2017)
* @since 1.4
*/
private static class SearchColumnOutsideGroupByHandler extends SearchColumnHandler {
@Override
protected boolean goInto(final ADQLObject obj){
return !(obj instanceof ClauseADQL<?> && ((ClauseADQL<?>)obj).getName().equalsIgnoreCase("GROUP BY")) && super.goInto(obj);
return !(obj instanceof ClauseADQL<?> && ((ClauseADQL<?>)obj).getName() != null && ((ClauseADQL<?>)obj).getName().equalsIgnoreCase("GROUP BY")) && super.goInto(obj);
}
}
......
......@@ -96,6 +96,23 @@ public class TestDBChecker {
assertEquals(expected[i], names[i]);
}
@Test
public void testClauseADQLWithNameNull(){
/* The name of an ADQLClause is got in DBChecker by SearchColumnOutsideGroupByHandler.goInto(...)
* and possibly in other locations in the future. If this name is NULL, no NullPointerException
* should be thrown.
*
* This issue can be tested by creating a ConstraintsGroup (i.e. in a constraints location like WHERE or JOIN...ON,
* a constraint (or more) between parenthesis). */
ADQLParser parser = new ADQLParser(new DBChecker(tables, new ArrayList<FunctionDef>(0)));
try{
parser.parseQuery("SELECT * FROM foo WHERE (colI BETWEEN 1 AND 10)");
}catch(ParseException pe){
pe.printStackTrace();
fail();
}
}
@Test
public void testGroupByWithQualifiedColName(){
ADQLParser parser = new ADQLParser(new DBChecker(tables, new ArrayList<FunctionDef>(0)));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment