-
Notifications
You must be signed in to change notification settings - Fork 583
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
Support for SIMILAR TO
syntax, change Like
and ILike
to Expr
variants, allow escape char for like/ilike
#569
Conversation
… escape char to like/ilike
Pull Request Test Coverage Report for Build 2842050083
💛 - Coveralls |
SIMILAR TO
syntax, change Like
and ILike
to Expr
variants, allow escape char for like/ilike
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @ayushdg -- this code looks great. Thank you for the contribution.
I think the copyright comments need to be addressed and a few more test cases added, but otherwise this PR is looking ready to go!
@@ -438,6 +461,72 @@ impl fmt::Display for Expr { | |||
high | |||
), | |||
Expr::BinaryOp { left, op, right } => write!(f, "{} {} {}", left, op, right), | |||
Expr::Like { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems to match https://www.postgresql.org/docs/current/functions-matching.html so 👍
@@ -76,10 +78,6 @@ pub enum BinaryOperator { | |||
And, | |||
Or, | |||
Xor, | |||
Like, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
BinaryOperator::Like | ||
}, | ||
right: Box::new(Expr::Value(Value::SingleQuotedString("%a".to_string()))), | ||
Expr::Like { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please also extend the parse_like
and parse_ilike
tests to include coverage of escape_char
for both LIKE
and ILIKE
?
tests/sqlparser_common.rs
Outdated
select.selection.unwrap() | ||
); | ||
|
||
// This statement tests that LIKE and NOT LIKE have the same precedence. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment appears to be out of date
Marking this as a draft to show it is waiting some changes so I can easily filter out which PRs need review. Please mark it as "ready for review" when it is next ready. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM -- thanks again @ayushdg !
I believe a new version of rust has been released so we need to update lint on master (unrelated to this change) |
…variants, allow escape char for like/ilike (apache#569) * Remove [not]like,[not]ilike from binary operator list * Add like, ilike and similar as an expr variant. Also adds support for escape char to like/ilike * Add parsing logic for similar to, update parsing logic for like/ilike * Add tests for similar to, update tests for like/ilike * Fix linter warnings * remove additional copyright license from files * Add more coverage w/wo escape char for like,ilike,similar to
…variants, allow escape char for like/ilike (apache#569) * Remove [not]like,[not]ilike from binary operator list * Add like, ilike and similar as an expr variant. Also adds support for escape char to like/ilike * Add parsing logic for similar to, update parsing logic for like/ilike * Add tests for similar to, update tests for like/ilike * Fix linter warnings * remove additional copyright license from files * Add more coverage w/wo escape char for like,ilike,similar to
…variants, allow escape char for like/ilike (apache#569) * Remove [not]like,[not]ilike from binary operator list * Add like, ilike and similar as an expr variant. Also adds support for escape char to like/ilike * Add parsing logic for similar to, update parsing logic for like/ilike * Add tests for similar to, update tests for like/ilike * Fix linter warnings * remove additional copyright license from files * Add more coverage w/wo escape char for like,ilike,similar to Can drop this after rebase on commit f07063f " Support for SIMILAR TO syntax, change Like and ILike to Expr variants, allow escape char for like/ilike (apache#569)", first released in 0.21.0
…variants, allow escape char for like/ilike (apache#569) * Remove [not]like,[not]ilike from binary operator list * Add like, ilike and similar as an expr variant. Also adds support for escape char to like/ilike * Add parsing logic for similar to, update parsing logic for like/ilike * Add tests for similar to, update tests for like/ilike * Fix linter warnings * remove additional copyright license from files * Add more coverage w/wo escape char for like,ilike,similar to Can drop this after rebase on commit f07063f " Support for SIMILAR TO syntax, change Like and ILike to Expr variants, allow escape char for like/ilike (apache#569)", first released in 0.21.0
This pr adds support for the
similar to
sql operator syntax and also adds support to provide escape char to the[Not] like/ilike
operators.