-
Notifications
You must be signed in to change notification settings - Fork 620
Add support for MySQL MEMBER OF #1917
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
Conversation
src/ast/mod.rs
Outdated
/// <value> MEMBER OF(<array>) | ||
/// ``` | ||
/// [MySQL](https://dev.mysql.com/doc/refman/8.4/en/json-search-functions.html#operator_member-of) | ||
MemberOf(Box<Expr>, Box<Expr>), |
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.
Can we introduce a struct for the expression e.g. MemberOf(MemberOf{ value, json })
? That way it would be less breaking if spans or other options are added to the expression later on
|
||
#[test] | ||
fn parse_json_member_of() { | ||
mysql().verified_stmt(r#"SELECT 17 MEMBER OF('[23, "abc", 17, "ab", 10]')"#); |
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.
For one of the tests can we assert the reurned expr that it contains the expected values in the expected fields in the AST?
src/parser/mod.rs
Outdated
let _ = self.expect_token(&Token::LParen); | ||
let expr2 = self.parse_expr()?; | ||
let _ = self.expect_token(&Token::RParen); |
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.
It looks like we're dropping potential error returned by the expect_token calls (we should probably add a test case for this behavior)?
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.
Updated, I'm just a bit rusty :-) ...
47c3ce1
to
0b74460
Compare
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 @yoavcloud!
cc @alamb
https://dev.mysql.com/doc/refman/8.4/en/json-search-functions.html#operator_member-of