Skip to content

Commit 4b010ce

Browse files
David EllingsworthDavid Ellingsworth
David Ellingsworth
authored and
David Ellingsworth
committed
nhibernateGH-3530: Firebird incorrectly uses the current culture to convert dates stores as strings. Address this issue by adding a FirebirdDbDataReader.
1 parent ec49d5f commit 4b010ce

File tree

3 files changed

+76
-1
lines changed

3 files changed

+76
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Data.Common;
4+
using System.Globalization;
5+
using System.Linq;
6+
using System.Text;
7+
using System.Threading.Tasks;
8+
using NHibernate.Id.Insert;
9+
10+
namespace NHibernate.AdoNet
11+
{
12+
public class FirebirdDbDataReader : DbDataReaderWrapper
13+
{
14+
public FirebirdDbDataReader(DbDataReader reader) : base(reader) { }
15+
16+
public override DateTime GetDateTime(int ordinal)
17+
{
18+
var value = DataReader[ordinal];
19+
20+
return value switch
21+
{
22+
string s => DateTime.Parse(s, CultureInfo.InvariantCulture),
23+
_ => (DateTime) value
24+
};
25+
}
26+
}
27+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
//------------------------------------------------------------------------------
2+
// <auto-generated>
3+
// This code was generated by AsyncGenerator.
4+
//
5+
// Changes to this file may cause incorrect behavior and will be lost if
6+
// the code is regenerated.
7+
// </auto-generated>
8+
//------------------------------------------------------------------------------
9+
10+
11+
using System;
12+
using System.Collections.Generic;
13+
using System.Data;
14+
using System.Data.Common;
15+
using System.Linq;
16+
using System.Reflection;
17+
using System.Text.RegularExpressions;
18+
using NHibernate.AdoNet;
19+
using NHibernate.Dialect;
20+
using NHibernate.SqlCommand;
21+
using NHibernate.SqlTypes;
22+
using NHibernate.Util;
23+
using Environment = NHibernate.Cfg.Environment;
24+
25+
namespace NHibernate.Driver
26+
{
27+
using System.Threading.Tasks;
28+
using System.Threading;
29+
public partial class FirebirdClientDriver : ReflectionBasedDriver
30+
{
31+
32+
public override async Task<DbDataReader> ExecuteReaderAsync(DbCommand command, CancellationToken cancellationToken)
33+
{
34+
cancellationToken.ThrowIfCancellationRequested();
35+
var reader = await (command.ExecuteReaderAsync(cancellationToken)).ConfigureAwait(false);
36+
37+
return new FirebirdDbDataReader(reader);
38+
}
39+
}
40+
}

src/NHibernate/Driver/FirebirdClientDriver.cs

+9-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System.Linq;
66
using System.Reflection;
77
using System.Text.RegularExpressions;
8+
using NHibernate.AdoNet;
89
using NHibernate.Dialect;
910
using NHibernate.SqlCommand;
1011
using NHibernate.SqlTypes;
@@ -17,7 +18,7 @@ namespace NHibernate.Driver
1718
/// A NHibernate Driver for using the Firebird data provider located in
1819
/// <c>FirebirdSql.Data.FirebirdClient</c> assembly.
1920
/// </summary>
20-
public class FirebirdClientDriver : ReflectionBasedDriver
21+
public partial class FirebirdClientDriver : ReflectionBasedDriver
2122
{
2223
private const string SELECT_CLAUSE_EXP = @"(?<=\bselect\b|\bwhere\b).*";
2324
private const string CAST_PARAMS_EXP =
@@ -212,5 +213,12 @@ public void ClearPool(string connectionString)
212213
/// See http://tracker.firebirdsql.org/browse/DNET-766.
213214
/// </summary>
214215
public override bool SupportsEnlistmentWhenAutoEnlistmentIsDisabled => false;
216+
217+
public override DbDataReader ExecuteReader(DbCommand command)
218+
{
219+
var reader = command.ExecuteReader();
220+
221+
return new FirebirdDbDataReader(reader);
222+
}
215223
}
216224
}

0 commit comments

Comments
 (0)