Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion spec/src/antlr/JQL-core.g4
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ conditional_expression

comparison_expression : scalar_expression comparison_operator scalar_expression;
between_expression : scalar_expression 'NOT'? 'BETWEEN' scalar_expression 'AND' scalar_expression;
like_expression : scalar_expression 'NOT'? 'LIKE' literal_pattern;
like_expression : scalar_expression 'NOT'? 'LIKE' escaped_pattern;

comparison_operator
: '='
Expand All @@ -64,6 +64,11 @@ comparison_operator
| '<>'
;

escaped_pattern
: literal_pattern
('ESCAPE' escape_character)?
;

in_expression : simple_path_expression 'NOT'? 'IN' in_item_list;
in_item_list : '(' in_item (',' in_item)* ')' ;
in_item : literal | enum_literal | input_parameter;
Expand Down Expand Up @@ -135,3 +140,5 @@ string_literal : STRING;

literal_pattern : STRING;

escape_character : CHARACTER;

6 changes: 5 additions & 1 deletion spec/src/antlr/JQL-full.g4
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,11 @@ in_item

like_expression
: string_expression
'NOT'? 'LIKE' pattern_value
'NOT'? 'LIKE' escaped_pattern
;

escaped_pattern
: pattern_value
('ESCAPE' escape_character)?
;

Expand Down
7 changes: 2 additions & 5 deletions spec/src/main/asciidoc/chapters/language/expressions.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ A `like` expression has syntax given by `like_expression`.

- Its left operand must be an expression assigned some atomic type representing character strings.
- Its right operand must be a pattern given as a literal string, with syntax `literal_pattern`, or, in the extended language, a <<parameters,parameter>>.

- Optionally, its right operand may specify an `escape_character` as a literal single character.

If an implementation of Jakarta Query targets clients written in Java, it must allow expressions assigned the type `java.lang.String` as the left operand of a `like` expression.

Expand All @@ -463,20 +463,17 @@ The expression is satisfied when its left operand evaluates to a non-null value
- the `not` keyword occurs, and the value does not match the pattern.

Matching is lexicographic.
Within the pattern, the characters `_` and `%` are interpreted as wildcards:
Within the pattern, the character bigram `''` is interpreted as a literal `'`, and the characters `_` and `%` are interpreted as wildcards:

- `_` matches any single character, and
- `%` matches any contiguous sequence of (zero or more) characters.

Any other character occurring in the pattern is interpreted literally and matches only itself.

In the extended language, a `like_expression` may specify an `#escape_character#`.
An escape character may be used to suppress the interpretation as a wildcard of a particular `_` or `%` character in the pattern.

That is, if the escape character is `c`, then the character bigram `c_` is interpreted literally as the character `_`, the bigram `c%` as the character `%`, and the bigram `cc` as the character `c`.

**TODO** add the escape character to the core language because it is needed by Jakarta Data's Like constraint

[[equality-and-inequality]]
==== Equality and inequality operators

Expand Down