Skip to content

Commit b8cd7f4

Browse files
NH-4017 - Npgsql v3 expects TimeSpan for time.
1 parent c3634f9 commit b8cd7f4

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/NHibernate/Driver/NpgsqlDriver.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
using System;
12
using System.Data;
23
using System.Data.Common;
4+
using System.Linq;
35

46
namespace NHibernate.Driver
57
{
@@ -84,5 +86,9 @@ protected override void InitializeParameter(DbParameter dbParam, string name, Sq
8486
if (sqlType.DbType == DbType.Currency)
8587
dbParam.DbType = DbType.Decimal;
8688
}
89+
90+
// Prior to v3, Npgsql was expecting DateTime for time.
91+
// https://github.com/npgsql/npgsql/issues/347
92+
public override bool RequiresTimeSpanForTime => (DriverVersion?.Major ?? 3) >= 3;
8793
}
8894
}

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)