Skip to content

Commit 4572948

Browse files
NH-3919 - Firebird fix for connection releasing, to be squashed
1 parent 1f35225 commit 4572948

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

src/NHibernate.Test/Async/TypesTest/DateTimeTypeFixture.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,12 @@ protected override void OnTearDown()
101101
}
102102
}
103103

104+
protected override void DropSchema()
105+
{
106+
(Sfi.ConnectionProvider.Driver as ClientDriverWithParamsStats)?.CleanUp();
107+
base.DropSchema();
108+
}
109+
104110
[Test]
105111
public Task DbHasExpectedTypeAsync()
106112
{

src/NHibernate.Test/TypesTest/DateTimeTypeFixture.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,12 @@ protected override void OnTearDown()
121121
}
122122
}
123123

124+
protected override void DropSchema()
125+
{
126+
(Sfi.ConnectionProvider.Driver as ClientDriverWithParamsStats)?.CleanUp();
127+
base.DropSchema();
128+
}
129+
124130
[Test]
125131
public void DbHasExpectedType()
126132
{
@@ -290,6 +296,24 @@ DbParameter IDriver.GenerateParameter(DbCommand command, string name, SqlType sq
290296
return param;
291297
}
292298

299+
#region Firebird mess
300+
301+
public void CleanUp()
302+
{
303+
if (_driverImplementation is FirebirdClientDriver fbDriver)
304+
{
305+
// Firebird will pool each connection created during the test and will marked as used any table
306+
// referenced by queries. It will at best delays those tables drop until connections are actually
307+
// closed, or immediately fail dropping them.
308+
// This results in other tests failing when they try to create tables with same name.
309+
// By clearing the connection pool the tables will get dropped. This is done by the following code.
310+
// Moved from NH1908 test case, contributed by Amro El-Fakharany.
311+
fbDriver.ClearPool(null);
312+
}
313+
}
314+
315+
#endregion
316+
293317
#region Pure forwarding
294318

295319
void IDriver.Configure(IDictionary<string, string> settings)

0 commit comments

Comments
 (0)