Skip to content
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

Fix parsing of equality binop in function argument #1182

Merged
merged 1 commit into from
Apr 6, 2024

Conversation

jmhain
Copy link
Contributor

@jmhain jmhain commented Mar 15, 2024

#1057 added support for using the = operator for named function arguments. This syntax conflicts with passing an = binop expr as a function argument, and so this caused a regression on dialects that don't support this style of named argument. There were two problems in particular:

  1. foo(a = b) would parse as a named argument rather than a comparison of a and b.
  2. foo(1=1) resulted in a parsing failure, which is problematic as many people have the habit of writing 1=1 instead of TRUE.

So rather than accepting this everywhere, we should only accept it on dialects that have this form of named argument. The original PR only mentions DuckDB so that's the only dialect I enabled it for. If there are any others, please let me know and I'll add them.

@coveralls
Copy link

Pull Request Test Coverage Report for Build 8455341031

Details

  • 25 of 29 (86.21%) changed or added relevant lines in 5 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.001%) to 87.88%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/dialect/duckdb.rs 1 2 50.0%
src/dialect/mod.rs 1 2 50.0%
src/test_utils.rs 6 7 85.71%
tests/sqlparser_common.rs 15 16 93.75%
Totals Coverage Status
Change from base Build 8411261926: -0.001%
Covered Lines: 20506
Relevant Lines: 23334

💛 - Coveralls

Copy link
Collaborator

@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.

Thanks @jmhain -- this looks good to me.

options: None,
}
}

/// Returns all dialects matching the given predicate.
pub fn all_dialects_where<F>(predicate: F) -> TestedDialects
Copy link
Collaborator

Choose a reason for hiding this comment

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

I appreciate this improvement of the code while you were in here. Thank you

@alamb alamb merged commit 3bf4048 into sqlparser-rs:main Apr 6, 2024
10 checks passed
@jmhain jmhain deleted the eq-binop-in-fn-arg branch April 6, 2024 18:09
JichaoS pushed a commit to luabase/sqlparser-rs that referenced this pull request May 7, 2024
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.

None yet

3 participants