Skip to content

Fix for Postgres regex and like binary operators #1928

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

solontsev
Copy link
Contributor

@solontsev solontsev commented Jul 6, 2025

Closes #1776

Currently, when parsing expressions with regex and like operators, only literals are supported, while the following syntax is also valid (matching against an array of values using ALL or ANY):

... where a ~ any(array['x'])

or

select a ~ any(array['x'])

@solontsev solontsev marked this pull request as ready for review July 6, 2025 08:30
}),
select.projection[0]
);

// Binary operator with ALL operator
let select =
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure I fully understood the fix, is the issue specific to the ALL and ANY functions? the current test doesn't seem to make changes to the list of operators being tested so that its not clear to me why this test fails without the fix in this PR

Copy link
Contributor Author

@solontsev solontsev Jul 8, 2025

Choose a reason for hiding this comment

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

Currently, when parsing expressions with regex and like operators, only literals are supported, while syntax like where a ~ any(array['x']) is also valid (matching against an array of values using ALL or ANY). I've added additional more complex expressions to the tests (fails with the current version) + allowed 8 more operators before the ALL and ANY functions in the parse_infix function.

| BinaryOperator::PGRegexMatch
| BinaryOperator::PGRegexIMatch
| BinaryOperator::PGRegexNotMatch
| BinaryOperator::PGRegexNotIMatch
| BinaryOperator::PGLikeMatch
| BinaryOperator::PGILikeMatch
| BinaryOperator::PGNotLikeMatch
| BinaryOperator::PGNotILikeMatch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Postgres dialect fails to parse "~ any(...)"
2 participants