Skip to content

Conversation

@ReppCodes
Copy link
Contributor

We already support most postgres jsonb operators, but were missing the ?-based ones. This commit adds support for them in both the tokenizer and the AST enums. This is simplified in the tokenizer with a dialect-specific carve-out, since Postgres thankfully does not also use ? for anonymous prepared statement parameters.

This resolves #1236

@coveralls
Copy link

coveralls commented Apr 29, 2024

Pull Request Test Coverage Report for Build 8901370315

Details

  • 56 of 62 (90.32%) changed or added relevant lines in 5 files are covered.
  • 3 unchanged lines in 2 files lost coverage.
  • Overall coverage decreased (-0.001%) to 89.185%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/tokenizer.rs 6 9 66.67%
tests/sqlparser_postgres.rs 27 30 90.0%
Files with Coverage Reduction New Missed Lines %
src/tokenizer.rs 1 90.18%
tests/sqlparser_common.rs 2 89.59%
Totals Coverage Status
Change from base Build 8901358862: -0.001%
Covered Lines: 23948
Relevant Lines: 26852

💛 - Coveralls

Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

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

Thank you @ReppCodes - this looks great. I think we need a few more tests but otherwise 👨‍🍳 👌

Note @jmhain made some significant changes to how json access is represented in #1215

I think we should merge that PR first and then this PR

select.selection.unwrap(),
);

let sql = r#"SELECT info FROM orders WHERE info ? 'b'"#;
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 please add coverage for all new operators that were added?

Perhaps just verifying that they roundtrip ( no need to reverify the parsed structure for all of them), perhaps using one_statement_parses_to or something similar

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@alamb The tests at lines 2373 and at 2390 should cover the other of the three new operators added, I believe? Sorry, not sure what I'm missing here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also, I'm cleaning up the conflicts after getting that refactor merged in. Should be up shortly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

And done. Assuming the three added tests hit the operators as needed, should be good to go. Just let me know!

Thanks!

Copy link
Contributor

Choose a reason for hiding this comment

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

Yup --- looks good to me. Thank you (I think it was unclear to me that only three new operators got added initially). Sorry for my confusion

We already support most postgres jsonb operators, but were missing the
?-based ones. This commit adds support for them in both the tokenizer
and the AST enums.  This is simplified in the tokenizer with a
dialect-specific carve-out, since Postgres thankfully does not also use
? for anonymous prepared statement parameters.
Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

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

Thank you @ReppCodes -- looks like a very nice contribution to me 🙏

select.selection.unwrap(),
);

let sql = r#"SELECT info FROM orders WHERE info ? 'b'"#;
Copy link
Contributor

Choose a reason for hiding this comment

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

Yup --- looks good to me. Thank you (I think it was unclear to me that only three new operators got added initially). Sorry for my confusion

@alamb alamb merged commit 4aa37a4 into apache:main May 1, 2024
JichaoS pushed a commit to luabase/sqlparser-rs that referenced this pull request May 7, 2024
Co-authored-by: Andrew Repp <arepp@cloudflare.com>
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.

Missing support for some Postgres operators

3 participants