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

Support the new BCL DateOnly and TimeOnly structs for Sqlite #24506

Closed
roji opened this issue Mar 25, 2021 · 7 comments · Fixed by #24989
Closed

Support the new BCL DateOnly and TimeOnly structs for Sqlite #24506

roji opened this issue Mar 25, 2021 · 7 comments · Fixed by #24989
Assignees
Labels
area-adonet-sqlite area-sqlite closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-enhancement
Milestone

Comments

@roji
Copy link
Member

roji commented Mar 25, 2021

New DateOnly and TimeOnly structs are being introduced to .NET 6 as alternatives to DateTime (dotnet/runtime#49036). This issue tracks supporting them in Sqlite (both ADO.NET and EF Core providers).

@bricelam
Copy link
Contributor

The DateOnly translations will be the same as the current DateTime translations but using date() instead of datetime().
The TimeOfDay translations will be the same as the ones listed in issue #18844, but using time() (well actually strftime('%H:%M:%f') to preserve precision) instead of ef_timespan(), and julianday() instead of ef_days().

Additional translations:

.NET SQL
date + time $date || ' ' || $time

The ADO.NET provider should serialize and deserialize these to TEXT using the hh\:mm\:ss.fff custom format for TimeOfDay and yyyy\-MM\-dd for DateOnly. EF Core literals should use these same formats.

@bricelam
Copy link
Contributor

bricelam commented Mar 26, 2021

On a related note, we should look into updating the DateTime, DateTimeOffset, and TimeSpan formats to use fff instead of FFFFFFF.

This would be a breaking change, but also enables us to get rid of the ugly rtrim calls in the SQL.

@mattjohnsonpint
Copy link

Why truncate precision to milliseconds?

@bricelam
Copy link
Contributor

SQLite date and time functions only go to milliseconds. We could allow reading and writing values with higher precision—we do this today for DateTime. But any arithmetic operations on the server will have to truncate. (Unless we add our own UDFs, but IMHO that’s going too far to work around SQLite’s native limitations.)

@mattjohnsonpint
Copy link

Please note that the final names for these types are DateOnly and TimeOnly and that they are now merged into the main branch for the next version of .NET 6 (preview 4 likely). Please rename the title of this issue accordingly. Thanks.

@roji roji changed the title Support the new BCL DateOnly and TimeOfDay structs for Sqlite Support the new BCL DateOnly and TimeOnly structs for Sqlite Apr 15, 2021
@bricelam bricelam self-assigned this May 5, 2021
@bricelam bricelam removed this from the Backlog milestone May 6, 2021
@ajcvickers ajcvickers added this to the Backlog milestone May 7, 2021
@roji roji removed this from the Backlog milestone May 16, 2021
@roji
Copy link
Member Author

roji commented May 16, 2021

Clearing milestone to discuss doing this in 6.0.0.

@roji
Copy link
Member Author

roji commented May 27, 2021

Poaching

@roji roji assigned roji and unassigned bricelam May 27, 2021
roji added a commit that referenced this issue May 27, 2021
@roji roji added closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. and removed consider-for-current-release consider-for-next-release labels May 27, 2021
roji added a commit that referenced this issue Jun 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-adonet-sqlite area-sqlite closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants