Skip to content

Commit

Permalink
Handle != as NOT EQUALS for JPQL.
Browse files Browse the repository at this point in the history
See #3061.
  • Loading branch information
gregturn committed Jul 11, 2023
1 parent efdb289 commit cc34823
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ update_clause
;

update_item
: (identification_variable '.')? (single_valued_embeddable_object_field '.')* (state_field | single_valued_object_field) '=' new_value
: (identification_variable '.')? (single_valued_embeddable_object_field '.')* (state_field | single_valued_object_field) EQUAL new_value
;

new_value
Expand Down Expand Up @@ -377,21 +377,21 @@ all_or_any_expression

comparison_expression
: string_expression comparison_operator (string_expression | all_or_any_expression)
| boolean_expression op=('=' | '<>') (boolean_expression | all_or_any_expression)
| enum_expression op=('=' | '<>') (enum_expression | all_or_any_expression)
| boolean_expression op=(EQUAL | NOT_EQUAL) (boolean_expression | all_or_any_expression)
| enum_expression op=(EQUAL | NOT_EQUAL) (enum_expression | all_or_any_expression)
| datetime_expression comparison_operator (datetime_expression | all_or_any_expression)
| entity_expression op=('=' | '<>') (entity_expression | all_or_any_expression)
| entity_expression op=(EQUAL | NOT_EQUAL) (entity_expression | all_or_any_expression)
| arithmetic_expression comparison_operator (arithmetic_expression | all_or_any_expression)
| entity_type_expression op=('=' | '<>') entity_type_expression
| entity_type_expression op=(EQUAL | NOT_EQUAL) entity_type_expression
;

comparison_operator
: op='='
: op=EQUAL
| op='>'
| op='>='
| op='<'
| op='<='
| op='<>'
| op=NOT_EQUAL
;

arithmetic_expression
Expand Down Expand Up @@ -841,6 +841,9 @@ VALUE : V A L U E;
WHEN : W H E N;
WHERE : W H E R E;

EQUAL : '=' ;
NOT_EQUAL : '<>' | '!=' ;


CHARACTER : '\'' (~ ('\'' | '\\')) '\'' ;
IDENTIFICATION_VARIABLE : ('a' .. 'z' | 'A' .. 'Z' | '\u0080' .. '\ufffe' | '$' | '_') ('a' .. 'z' | 'A' .. 'Z' | '\u0080' .. '\ufffe' | '0' .. '9' | '$' | '_')* ;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -948,4 +948,9 @@ void typeShouldBeAValidParameter() {
assertQuery("select e from Employee e where e.type = :_type");
assertQuery("select te from TestEntity te where te.type = :type");
}

@Test // GH-3061
void alternateNotEqualsOperatorShouldWork() {
assertQuery("select e from Employee e where e.firstName != :name");
}
}

0 comments on commit cc34823

Please sign in to comment.