-
Notifications
You must be signed in to change notification settings - Fork 934
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 SQLite SQL types registrations #2346
Fix SQLite SQL types registrations #2346
Conversation
Invalid types were declared in SQLite dialect, causing cast errors, and having led to an undue hack disabling casting for some types.
|
||
return ((DateTime)value).TimeOfDay; | ||
|
||
var dbValue = Convert.ToDateTime(value); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The direct cast was not failing thanks to having previously used the "internal use only" DATETIME
type, causing the data provider to do the convert itself. But this was also wrecking casting, and as documented in their chm, this type is not meant for being used outside of the provider itself.
So we need now to do the convert, as are already doing other NHibernate types dealing with DateTime
, see TimeType
by example.
To be squashed
To be squashed
Co-authored-by: maca88 <[email protected]>
Was this really a good call when it comes to Decimal? There's no controlling of the decimals count now, when further casting to string, for example, making reporting a pain, for example. Moreover, the SQLite data types manual specifies the affinity of DECIMAL(10,5) to NUMERIC, not REAL. |
There was never any actual control of decimal count with SQLite, it has no decimal support. It only has binary floats. |
You're right, I worded it ambiguously. I meant it more like decimals vs. no-decimals, because one now ends up with decimals where there were none previously, due to the replaced NUMERIC:
with REAL:
This is a breaking change, with the workaround to add an extra cast:
|
This case exploits some very specific behavior of SQLite, where a type that can handle a fractional part behaves as an integer regarding divisions if the provided number is integral. This looks to me as an extreme corner case. Better explicitly use integers where integer behavior is required. |
Invalid types were declared in SQLite dialect, causing cast errors, and having led to an undue hack disabling casting for some types.
Possible breaking change: in order to avoid a floating point division bug losing the fractional part, decimal are now stored as
REAL
instead ofNUMERIC
. Both are binary floating point types, excepted thatNUMERIC
stores integral values asINTEGER
. This change may cause big integral decimal values to lose more precision in SQLite.