Skip to content

Commit 3adb353

Browse files
NH-4017 - although not looking mandatory, added a version check for converting only if Npgsql v3 or higher is loaded.
1 parent be018d3 commit 3adb353

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/NHibernate/Driver/NpgsqlDriver.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,11 @@ protected override void InitializeParameter(DbParameter dbParam, string name, Sq
8989

9090
public override void AdjustCommand(DbCommand command)
9191
{
92+
if (DriverVersion?.Major < 3)
93+
// Prior to v3, Npgsql was expecting DateTime for time. Nothing to do.
94+
// https://github.com/npgsql/npgsql/issues/347
95+
return;
96+
9297
foreach (var parameter in command.Parameters.Cast<DbParameter>().Where(x => x.DbType == DbType.Time))
9398
{
9499
if (parameter.Value is DateTime dateTimeValue)

src/NHibernate/Driver/ReflectionBasedDriver.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System;
12
using System.Data.Common;
23
using NHibernate.Util;
34

@@ -12,6 +13,11 @@ public abstract class ReflectionBasedDriver : DriverBase
1213

1314
private readonly IDriveConnectionCommandProvider connectionCommandProvider;
1415

16+
/// <summary>
17+
/// If the driver use a third party driver (not a .Net Framework DbProvider), its assembly version.
18+
/// </summary>
19+
protected Version DriverVersion { get; }
20+
1521
/// <summary>
1622
/// Initializes a new instance of <see cref="ReflectionBasedDriver" /> with
1723
/// type names that are loaded from the specified assembly.
@@ -51,6 +57,7 @@ protected ReflectionBasedDriver(string providerInvariantName, string driverAssem
5157
else
5258
{
5359
connectionCommandProvider = new ReflectionDriveConnectionCommandProvider(connectionType, commandType);
60+
DriverVersion = connectionType.Assembly.GetName().Version;
5461
}
5562
}
5663

0 commit comments

Comments
 (0)