-
Notifications
You must be signed in to change notification settings - Fork 605
Support ANSI SQL datetime / interval literals #62
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
Comments
1) Removed unused date/time parsing methods from `Parser` I don't see how the token-based parsing code would ever be used: the date/time literals are usually quoted, like `DATE 'yyyy-mm-dd'` or simply `'YYYYMMDD'`, so the date will be a single token. 2) Removed unused date/time related variants from `Value` and the dependency on `chrono`. We don't support parsing date/time literals at the moment and when we do I think we should store the exact String to let the consumer parse it as they see fit. 3) Removed `parse_timestamps_example` and `parse_timestamps_with_millis_example` tests. They parsed as `number(2016) minus number(02) minus number(15) <END OF EXPRESSION>` (leaving the time part unparsed) as it makes no sense to try parsing a yyyy-mm-dd value as an SQL expression.
Some notes on INTERVALs in SQL: While reading through the grammar rules from the spec and the explanation, I made this cheatsheet for myself:
where The
The plus/minus sign is also allowed inside the quoted (Posgres allows omitting The |
Thanks to all the hard work by @benesch we now have support for DATE/TIME/INTERVAL literals, with the following caveats:
|
See:
<datetime literal>
--DATE 'yyyy-mm-dd'
and similar<interval literal>
--INTERVAL '5' DAY
<datetime value expression>
.An open question is whether the date/time values should store the string values intact or parse the strings and store them as
chrono
values as in the code I removed in https://github.com/andygrove/sqlparser-rs/pull/61 (andygrove@de177f1) - I'm leaning towards the former, so that a user of this library can choose the preferred representation.The text was updated successfully, but these errors were encountered: