-
Notifications
You must be signed in to change notification settings - Fork 934
Time is incompatible with bigint for TimeAsTimeSpanType #2963
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
That seems a bit odd. The error indicates that the datetime column is stored as a bigint, and it's coming from SQL Server.
is not valid, in that scenario. |
Does it work properly in 5.2? I suspect it's a regression caused by #2365 So in expression |
@bahusoid yes, that is correct. v5.2.7 doesn't have this issue 😄 At the same time, FluentNHibernate requires v5.3.3+dependency to fix Net 5.0: BinaryFormatter serialization and deserialization so that the Web app doesn't fail on startup. Hi @gliljas, if I understand you correctly, I should change RegisterFunction(nameof(Ext.GetTime),
new SQLFunctionTemplate(NHibernateUtil.WhichType, "sql_cast_conversion")); resulting in This is my first time on NHibernate issue, and I'm trying to figure out how to use the |
If it's the only reason to upgrade, try assembly binding redirect |
Thank you for the assistance 😄 Until 5.3.11 release, it's best to revert to v5.2.7 and apply binding redirect for FluentNHibernate. Tried couple of conversions, but the data types are not the same in comparison, resulting in SQL errors. RegisterFunction(nameof(Ext.GetTime),
new SQLFunctionTemplate(NHibernateUtil.TimeAsTimeSpan, "convert(char(8), ?1, 108)")); and there is no easy + performance way to convert the Ticks into SQL, that NHibernate generates from v5.3.10 --part of WHERE
and cast(item0_.Start as time) < 36000000000 /* @p6 */ v5.2.7 --part of WHERE
and cast(item0_.Start as time) < '01:00:00' /* @p6 */ |
I've made a PR that uses the guessed type only when the hql logic is not able to determine it (similar as in |
So it's a variation of #2723 in the end.
I didn't know it. So this breakage of some char related tests made me think it's not safe for 5.3...
What about the case when initial type is AnsiStringType. (something like |
Fixed by #2964 |
Context
Updating v5.1.7 to 5.3.10 together with FluentNHibernate 3.1.0
NHibernate LINQ providers don't support
DateTime.TimeOfDay
to automatically convert to SQLtime
Approach
RegisterFunction()
to the rescue to adjust the dialect, where in 5.1.7 the following code works for MS SQL 2012 dialectwhere
Ext.GetTime
only accessesTimeOfDay
Usage
Exception in 5.3.10
While v5.3.10 throws an exception
I understand TimeSpan can have more than 24h, whereas this method is used only for less than 24h intervals.
Related: TimeAsTimeSpanType has changes from v5.1.3 related to casting types to
TimeSpan
.Questions
Trying to figure out
InternalTicks
fromTimeOfDay
tries to map to SQL typetime
in NHibernateOpen to ideas how to contribute to documentation 😃
The text was updated successfully, but these errors were encountered: