-
Notifications
You must be signed in to change notification settings - Fork 934
Fix support for Npgsql6 provider #3064
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
dbParam.DbType = DbType.Decimal; | ||
} | ||
else if (DriverVersionMajor < 6 || sqlType.DbType != DbType.DateTime) |
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.
Mr. Smarty Pants.
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.
Hi!
I am sorry, it seems theese changes leads to an error in some cases.
Versions:
- NHibernate 5.4.2
- Npgsql 7.0.2
The named query:
<sql-query name="MyQuery" cache-mode="normal" read-only="true">
<query-param type="DateTime" name="DateOfSearch"/>
<return-scalar type="Int64" column="SomeID"/>
<![CDATA[select ...
from ...
where (( :DateOfSearch is null ) or (( t.DT1 <= :DateOfSearch) and ( t.DT2 >= :DateOfSearch )))
and ... ;]]>
</sql-query>
</hibernate-mapping>
Call the query:
DateTime? dateOfSearch = null; // set null value here -- !!!!
query.SetParameter("DateOfSearch", dateOfSearch, NHibernateUtil.DateTime);
var result = query.List<long>();
NHibernate log:
2023-04-21 23:01:51,433 [1] DEBUG NHibernate.Type.DateTimeType - binding null to parameter: 0
2023-04-21 23:01:51,433 [1] DEBUG NHibernate.Type.DateTimeType - binding null to parameter: 1
2023-04-21 23:01:51,434 [1] DEBUG NHibernate.Type.DateTimeType - binding null to parameter: 2
2023-04-21 23:01:51,445 [1] DEBUG NHibernate.SQL - select ...
from ...
where (( :p0 is null ) or (( mmh.DT_Mount <= :p0) and ( mmh.DT_Dismount >= :p0 ))); :p0 = NULL [Type: Object (0:0:0)] -- !!!!
...
2023-04-21 23:01:51,623 [1] ERROR NHibernate.AdoNet.AbstractBatcher - Could not execute query: select ...
dbParam.DBType is empty, and Npgsql sends Prepare command to PostgreSQL with no parameter type specified, but PostgreSQL also can not guess the type from this query and value.
It works correctly, if I set non-null parameter 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.
That point has been fixed by #3299.
Maybe we should consider porting this to 5.3 |
Ok for targeting 5.3.x, unless we consider releasing 5.4 soon. |
Ok, I've rebased to 5.3.x |
npgsql does not support .net core 2.1
Fixes #2994