PL-7539 Internal server error occurs if the JPQL query contains '@enum' in brackets

This commit is contained in:
Andrey Subbotin 2016-07-14 16:50:05 +04:00
parent 8424cb7135
commit 1c47e37092
5 changed files with 2062 additions and 1744 deletions

View File

@ -131,6 +131,18 @@ public class QueryParserAstBasedTest {
assertFalse(parser.hasIsNullCondition("model"));
}
@Test
public void testEnumMacro() {
DomainModel model = prepareDomainModel();
QueryParserAstBased parser = new QueryParserAstBased(model,
"select r from sec$Role r where r.type = @enum(com.haulmont.cuba.security.entity.RoleType.STANDARD)");
parser.getEntityName();
parser = new QueryParserAstBased(model,
"select r from sec$Role r where (select r1.type from sec$Role r1 where r1.id = r.id) = @enum(com.haulmont.cuba.security.entity.RoleType.STANDARD)");
parser.getEntityName();
}
@Test
public void testGetNestedEntityNameIfNestedSelected() throws Exception {
DomainModel model = prepareDomainModel();

View File

@ -461,7 +461,8 @@ nullif_expression
extension_functions
: 'CAST(' function_arg WORD ('('INT_NUMERAL (',' INT_NUMERAL)* ')')* ')'
| 'EXTRACT(' date_part 'FROM' function_arg ')';
| 'EXTRACT(' date_part 'FROM' function_arg ')'
| '@ENUM' '(' enum_value_literal ')';
fragment date_part
: 'EPOCH' | 'YEAR' | 'QUARTER' | 'MONTH' | 'WEEK' |'DAY' | 'HOUR' |'MINUTE' | 'SECOND';
@ -532,6 +533,8 @@ collection_valued_input_parameter
: input_parameter;
single_valued_input_parameter
: input_parameter;
enum_value_literal
: WORD ('.' WORD)*;
// Lexical Rules
//fix trim character

View File

@ -85,6 +85,7 @@ T__139=139
T__140=140
T__141=141
T__142=142
T__143=143
AND=4
ASC=5
AVG=6
@ -158,95 +159,96 @@ WS=55
'@DATEAFTER'=72
'@DATEBEFORE'=73
'@DATEEQUALS'=74
'@TODAY'=75
'ABS('=76
'ALL'=77
'@ENUM'=75
'@TODAY'=76
'ABS('=77
'ALL'=78
'AND'=4
'ANY'=78
'AS'=79
'ANY'=79
'AS'=80
'ASC'=5
'AVG'=6
'BETWEEN'=80
'BOTH'=81
'BETWEEN'=81
'BOTH'=82
'BY'=7
'CASE'=82
'CAST('=83
'COALESCE('=84
'CONCAT('=85
'CASE'=83
'CAST('=84
'COALESCE('=85
'CONCAT('=86
'COUNT'=9
'CURRENT_DATE'=86
'CURRENT_TIME'=87
'CURRENT_TIMESTAMP'=88
'DAY'=89
'DELETE'=90
'CURRENT_DATE'=87
'CURRENT_TIME'=88
'CURRENT_TIMESTAMP'=89
'DAY'=90
'DELETE'=91
'DESC'=10
'DISTINCT'=11
'ELSE'=91
'EMPTY'=92
'END'=93
'ENTRY('=94
'EPOCH'=95
'ESCAPE'=96
'EXISTS'=97
'EXTRACT('=98
'ELSE'=92
'EMPTY'=93
'END'=94
'ENTRY('=95
'EPOCH'=96
'ESCAPE'=97
'EXISTS'=98
'EXTRACT('=99
'FETCH'=13
'FROM'=99
'FUNCTION('=100
'FROM'=100
'FUNCTION('=101
'GROUP'=14
'HAVING'=15
'HOUR'=101
'HOUR'=102
'IN'=16
'INDEX('=102
'INDEX('=103
'INNER'=17
'IS'=103
'IS'=104
'JOIN'=19
'KEY('=104
'LEADING'=105
'KEY('=105
'LEADING'=106
'LEFT'=20
'LENGTH('=106
'LIKE'=107
'LOCATE('=108
'LENGTH('=107
'LIKE'=108
'LOCATE('=109
'LOWER'=22
'MAX'=24
'MEMBER'=109
'MEMBER'=110
'MIN'=25
'MINUTE'=110
'MOD('=111
'MONTH'=112
'NEW'=113
'MINUTE'=111
'MOD('=112
'MONTH'=113
'NEW'=114
'NOT'=27
'NOW'=114
'NULL'=115
'NULLIF('=116
'OBJECT'=117
'OF'=118
'ON'=119
'NOW'=115
'NULL'=116
'NULLIF('=117
'OBJECT'=118
'OF'=119
'ON'=120
'OR'=28
'ORDER'=29
'OUTER'=30
'QUARTER'=120
'REGEXP'=121
'SECOND'=122
'SELECT'=123
'QUARTER'=121
'REGEXP'=122
'SECOND'=123
'SELECT'=124
'SET'=33
'SIZE('=124
'SOME'=125
'SQRT('=126
'SUBSTRING('=127
'SIZE('=125
'SOME'=126
'SQRT('=127
'SUBSTRING('=128
'SUM'=35
'THEN'=128
'TRAILING'=129
'TREAT('=130
'TRIM('=131
'TYPE('=132
'UPDATE'=133
'UPPER('=134
'VALUE('=135
'WEEK'=136
'WHEN'=137
'WHERE'=138
'YEAR'=139
'THEN'=129
'TRAILING'=130
'TREAT('=131
'TRIM('=132
'TYPE('=133
'UPDATE'=134
'UPPER('=135
'VALUE('=136
'WEEK'=137
'WHEN'=138
'WHERE'=139
'YEAR'=140
'\'.\''=36
'false'=140
'true'=141
'}'=142
'false'=141
'true'=142
'}'=143