Skip to content

Commit 15575b4

Browse files
NH-1752 - Handling MinDate per driver for tests.
1 parent 37ec8d1 commit 15575b4

File tree

7 files changed

+25
-5
lines changed

7 files changed

+25
-5
lines changed

src/NHibernate.Test/TypesTest/DateTypeTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public void ReadWriteNormal()
6868
[Test]
6969
public void ReadWriteMin()
7070
{
71-
var expected = DateTime.MinValue;
71+
var expected = Sfi.ConnectionProvider.Driver.MinDate;
7272

7373
ReadWrite(expected);
7474
}

src/NHibernate/Driver/DriverBase.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,5 +321,8 @@ public DbParameter GenerateOutputParameter(DbCommand command)
321321
public virtual bool SupportsEnlistmentWhenAutoEnlistmentIsDisabled => true;
322322

323323
public virtual bool HasDelayedDistributedTransactionCompletion => false;
324+
325+
/// <inheritdoc />
326+
public virtual DateTime MinDate => DateTime.MinValue;
324327
}
325-
}
328+
}

src/NHibernate/Driver/IDriver.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,5 +158,10 @@ public interface IDriver
158158
/// crash due to this, because they re-use the connection in the second phase.
159159
/// </remarks>
160160
bool HasDelayedDistributedTransactionCompletion { get; }
161+
162+
/// <summary>
163+
/// The minimal date supported by this driver.
164+
/// </summary>
165+
DateTime MinDate { get; }
161166
}
162-
}
167+
}

src/NHibernate/Driver/OdbcDriver.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,5 +89,8 @@ protected override void InitializeParameter(DbParameter dbParam, string name, Sq
8989
/// Depends on target DB in the Odbc case. This in facts depends on both the driver and the database.
9090
/// </summary>
9191
public override bool HasDelayedDistributedTransactionCompletion => true;
92+
93+
/// <inheritdoc />
94+
public override DateTime MinDate => new DateTime(1753, 1, 1);
9295
}
9396
}

src/NHibernate/Driver/Sql2008ClientDriver.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,8 @@ protected override void InitializeParameter(DbParameter dbParam, string name, Sq
2323
}
2424

2525
public override bool RequiresTimeSpanForTime => true;
26+
27+
/// <inheritdoc />
28+
public override DateTime MinDate => DateTime.MinValue;
2629
}
2730
}

src/NHibernate/Driver/SqlClientDriver.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1+
using System;
12
using System.Data;
23
using System.Data.Common;
34
using System.Data.SqlClient;
45
using NHibernate.AdoNet;
5-
using NHibernate.Dialect;
66
using NHibernate.Engine;
77
using NHibernate.SqlTypes;
88

@@ -207,5 +207,8 @@ public override bool SupportsMultipleQueries
207207
/// right after the scope disposal.
208208
/// </summary>
209209
public override bool HasDelayedDistributedTransactionCompletion => true;
210+
211+
/// <inheritdoc />
212+
public override DateTime MinDate => new DateTime(1753, 1, 1);
210213
}
211214
}

src/NHibernate/Driver/SqlServerCeDriver.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,5 +145,8 @@ private void AdjustDbParamTypeForLargeObjects(DbParameter dbParam, SqlType sqlTy
145145
/// this case.
146146
/// </summary>
147147
public override bool SupportsEnlistmentWhenAutoEnlistmentIsDisabled => false;
148+
149+
/// <inheritdoc />
150+
public override DateTime MinDate => new DateTime(1753, 1, 1);
148151
}
149-
}
152+
}

0 commit comments

Comments
 (0)