Skip to content

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

Merged
merged 4 commits into from
Jul 3, 2025
Merged

Conversation

yoavcloud
Copy link
Contributor

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>),
Copy link
Contributor

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]')"#);
Copy link
Contributor

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?

Comment on lines 3614 to 3616
let _ = self.expect_token(&Token::LParen);
let expr2 = self.parse_expr()?;
let _ = self.expect_token(&Token::RParen);
Copy link
Contributor

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)?

Copy link
Contributor Author

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 :-) ...

@yoavcloud yoavcloud requested a review from iffyio July 1, 2025 13:03
Copy link
Contributor

@iffyio iffyio left a 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

@iffyio iffyio merged commit be2d2f1 into apache:main Jul 3, 2025
10 checks passed
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.

2 participants