-
Notifications
You must be signed in to change notification settings - Fork 27
DateOnly/TimeOnly support #307
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
Conversation
Fix formatting Fix tests
…oProvider.cs Co-authored-by: Oleg Shuruev <shuruev@gmail.com>
…oProvider.cs Co-authored-by: Oleg Shuruev <shuruev@gmail.com>
Draft implementation of support of DateOnly/TimeOnly types for MS SQL Server
temporary keep previous compilation variable as comment
- new SqlDml Methods for Time and Date - rename DateOnlyXxx and TimeOnlyXxx to DateXxx and TimeXxx to be related to with SQL - new SqlFunctionTypes & SqlNodeTypes
Only tests affected
and other minor changes
|
@SergeiPavlov, Is this a problem that there is no |
# Conflicts: # Orm/Xtensive.Orm.Tests/Upgrade/FullText/DomainUpgradeFullTextTest.cs # Orm/Xtensive.Orm/Orm/Providers/Expressions/ExpressionProcessor.cs # Orm/Xtensive.Orm/Sql/Info/DataTypeCollection.cs
Why no support? |
|
The guys in DPA are waiting for at least RC to work with it in development branch so it is mostly because of timings. I'm going to add it later. |
Upgrade to SqlClient 5.1.0 with DateOnly/TimeOnly support
Adds support for these new types of .NET6 to all supported storages. This PR includes #251 and makes some changes over it.
Main changes:
SqlDmlmethods for operations with these types, such as parts extraction, additions/subtractions, construction from parts, value conversion betweenDateTime,DateOnly,TimeOnlyandDateTimeOffset(when and if possible)ChangeFieldTypeHintis applied.Depending on storage,
TimeOnlyvalues will have different precision when stored - from 7 for MS SQL Server and Oracle, to six and sometimes 4 fractional digits. MySQL 5.5 (provider still exists thought it was excluded from the supported storages due to age age) has no support for time fractions.SQL types
DATEandTIMEare used forDateOnlyandTimeOnlyrespectively, except for Oracle in which there is noTIMEtype so we usedINTERVAL DAY (0) TO SECOND(7). TIME behavior on storage side differentiates between RDBMSs and .NET, for example even so MySQL can store more that 800 hours in TIME operation of adding interval to it will always have not more than 23 in 'hour' part as it is in .NET. Expect .NET-like operations.On data conversion in case some field (and underlying column) changes type between
DateTime/DateOnly/TimeOnly/DateTimeOffset, the conversion happens on storage side. We don't assume and use internal mechanisms whenever it is possible, but sometimes we have to. There is some variation of results of conversion.DateOnly-to-DateTimeconversion is predictable and uses zero-time across the board.TimeOnly-to-DateTimeconversion has a lot of difference:TIMEtoDATETIME2, MS SQL Server internal mechanisms use'1900-01-01'as date (under the hood it puts0000-00-00as date part but since it is invalid it replaces it with1900-01-01).0001-01-01is valid date, it was made so because naturallyto_timestamp(0)returns1970-01-01, not the0001-01-01. So, for people who work with PostgreSQL this date will be known and expected.0001-01-01.1900-01-01as date.TimeOnly-to-DateTimeOffsetis tricky too. Conversion uses same principals for date part as above but time zone part applied to the value changes depending on RDBMS and even value. For more context take a look atXtensive.Orm.Tests.Upgrade.DateTimeTypesDataConversionTestTimeOnly-to-DateOnlycauses an exception for all storages except for SQLite (but it's its own thing) for obvious reason.NOTE There is no support for TimeOnly(long ticks) constructor and TimeOnly.Ticks part yet.