Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: verify that invalid string literals in LIKE expression are a parse error #1280

Merged
merged 1 commit into from
May 22, 2024
Merged
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
7 changes: 7 additions & 0 deletions cesql/cesql_tck/like_expression.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,10 @@ tests:
- name: With type coercion from bool (4)
expression: "FALSE LIKE 'fal%'"
result: true

- name: Invalid string literal in comparison causes parse error
expression: "x LIKE 123"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The doesn't say that % is required, so why is this an error?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because the only valid string literals in CESQL are either single quoted or double quoted. So, since 123 is not quoted it is not a string literal. See the definition for LIKE here:

string-literal ::= ( "'" ( [^'] | "\'" )* "'" ) | ( '"' ( [^"] | '\"' )* '"')
like-operator ::= "LIKE"
not-operator ::= "NOT"
like-operation ::= expression not-operator? like-operator string-literal

Basically, the LIKE operator is ONLY defined where the right hand operand is a string literal, and string literals require a single or double quote

result: false
error: parse
eventOverrides:
x: "123"
Loading