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: Support expr instead of string for argument to interval #517

Merged
merged 2 commits into from Jun 13, 2022

Conversation

togami2864
Copy link
Contributor

In Big Query and MySQL, the following query is valid:

SELECT DATE_ADD(DATE "2008-12-25", INTERVAL 5 DAY);

https://cloud.google.com/bigquery/docs/reference/standard-sql/date_functions#date_add
https://www.w3schools.com/mysql/func_mysql_date_add.asp

But now if the expression is number, an error occurred because the type of the value in interval is String

value: String,

This PR replaces String with Expr to run correctly in Interval

One concern thing is that should I validate when the other dialect like PostgresSQL, sqlite. I don't know if the query is valid except for Big query and MySQL.

@46bit
Copy link

46bit commented Jun 9, 2022

Great to see this. There's related discussion in #298.

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.

Looks good to me -- thank you @togami2864

@alamb
Copy link
Collaborator

alamb commented Jun 12, 2022

@togami2864 -- there appear to be some CI failures

@togami2864
Copy link
Contributor Author

@alamb I fixed all CI failures. Thanks.

@coveralls
Copy link

Pull Request Test Coverage Report for Build 2487582432

  • 28 of 29 (96.55%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.03%) to 89.822%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/ast/value.rs 1 2 50.0%
Totals Coverage Status
Change from base Build 2450394803: 0.03%
Covered Lines: 8737
Relevant Lines: 9727

💛 - Coveralls

@alamb alamb changed the title fix: use expr instead of string in interval fix: Supprot expr instead of string for argument to interval Jun 13, 2022
@alamb alamb changed the title fix: Supprot expr instead of string for argument to interval fix: Support expr instead of string for argument to interval Jun 13, 2022
@alamb alamb merged commit d981f70 into sqlparser-rs:main Jun 13, 2022
@alamb
Copy link
Collaborator

alamb commented Jun 13, 2022

Thanks @togami2864

mobuchowski pushed a commit to mobuchowski/sqlparser-rs that referenced this pull request Aug 3, 2022
…qlparser-rs#517)

* fix: use expr instead of string in interval

* chore: resolve CI

Co-authored-by: togami2864 <yoshiaki.togami@plaid.co.jp>
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

4 participants