-
Notifications
You must be signed in to change notification settings - Fork 27
TimeOnly constructors support #321
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
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
and use it in TimeOnlyCompilers
+ Interval type has correct natilve type association (was already in use, see v11.Translator)
There is no way to control hours overflow, Even MAKETIME function returns NULL or max value if value is incorrect, this opens way to possibly corrupted query results which is bad
There is no way to control hours overflow, STRFTIME returns NULL if value is incorrect, this opens way to possibly corrupted query results which is bad.
+ ignored SQLite and MySQL in test for second variant of TimeConstruct
@SergeiPavlov do your team have any problems with this? |
AFAIK - no |
# Conflicts: # ChangeLog/7.1.0-RC2-dev.txt
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Adds support for
TimeOnly
constructors (from parts and from ticks) in queries for majority of providers.Some providers (or versions of them) require special and not the best way to construct
TIME
values but save way in terms of value range. If there is a function to create a time value, we use it (e.g. MS SQL Server from v11, PostgreSQL from v10). In other cases, there are following ways:00:00:00.000
time value;Both of them have certain overhead but the second one provides boundaries check and an exception will be thrown if cast from string fails, which is good. The first way will have value overflow problem when there are more than 24 hours, which is possible.
Cases when
TimeSpan.Ticks
is used as parameter value forTimeOnly(ticks)
constructor are handled additionally, to have less calculations.Excluded providers are: SQLite, MySQL providers. These RDBMSs have certain particularities which were disqualifying.
SQLite:
TIME
values can have range, which is wider thanTimeOnly
's range, for example, 24:05.xx.xxx is valid value. The other part of problem is that there is no way to guarantee correct value even if it is wrong (25:05:xx.xxx). Storage will return NULL instead of exception of some sort. NULL value may be valid in case ofNullable<TimeOnly>
persistent field which may cause wrong results of query. Value overflow is not an option because it also may lead to unexpected results.MySQL:
TIME
value have range from-838:59:59.000000
to838:59:59.000000
, which is part of the problem the second part is that even if hour part is 839, the storage does not throw any errors but return max value. If there was an overflow error we could mathematically overcome this problem by adding 815 hours and then subtracting this value from result time value, but we can't. Newer versions haveMAKE_TIME
function which also doesn't control parameters, even if string is used as value, it will returnNULL
which may be valid value.