Mysterious NPE in QueryTreeAnalyzer #496

This commit is contained in:
Andrey Subbotin 2018-09-12 09:49:28 +04:00
parent b1fa7a4af4
commit 6097afb82c
4 changed files with 3522 additions and 3492 deletions

View File

@ -120,6 +120,26 @@ public class QueryParserAstBasedTest {
assertTrue(paramNames.contains("par"));
}
@Test
public void testErrorsInJoin() {
try {
QueryParserAstBased parser = new QueryParserAstBased(prepareDomainModel(),
"select h, sum(u.int1) from sec$User u join u.group g join g.hierarchy hwhere u.constraint.id = :storeSelect group by h");
parser.getEntityName();
fail();
} catch (JpqlSyntaxException e) {
//Do nothing
}
try {
QueryParserAstBased parser = new QueryParserAstBased(prepareDomainModel(),
"select u from sec$User u join fetch u.group g");
parser.getEntityName();
fail();
} catch (JpqlSyntaxException e) {
//Do nothing
}
}
@Test
public void testUsedEntityNames() throws Exception {

View File

@ -88,7 +88,7 @@ ql_statement
: select_statement | update_statement | delete_statement;
select_statement
: sl='SELECT' select_clause from_clause (where_clause)? (groupby_clause)? (having_clause)? (orderby_clause)?
: sl='SELECT' select_clause from_clause (where_clause)? (groupby_clause)? (having_clause)? (orderby_clause)? EOF
-> ^(T_QUERY<QueryNode>[$sl] (select_clause)? from_clause (where_clause)? (groupby_clause)? (having_clause)? (orderby_clause)?);
update_statement

View File

@ -1,4 +1,4 @@
// $ANTLR 3.5.2 JPA2.g 2018-03-26 13:42:00
// $ANTLR 3.5.2 JPA2.g 2018-09-12 09:43:17
package com.haulmont.cuba.core.sys.jpql.antlr2;
@ -6,6 +6,9 @@ package com.haulmont.cuba.core.sys.jpql.antlr2;
import com.haulmont.cuba.core.sys.jpql.JPA2RecognitionException;
import org.antlr.runtime.*;
import java.util.Stack;
import java.util.List;
import java.util.ArrayList;
@SuppressWarnings("all")
public class JPA2Lexer extends Lexer {