Skip to content

Commit 1d1d052

Browse files
committed
Clear pool after DropSchema
1 parent 158a75a commit 1d1d052

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

src/NHibernate.Test/TestCase.cs

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ protected virtual string MappingsAssembly
7171
[OneTimeSetUp]
7272
public void TestFixtureSetUp()
7373
{
74+
7475
try
7576
{
7677
Configure();
@@ -292,7 +293,18 @@ protected virtual void AddMappings(Configuration configuration)
292293

293294
protected virtual void CreateSchema()
294295
{
295-
if (Sfi?.ConnectionProvider.Driver is FirebirdClientDriver fbDriver)
296+
using (var optionalConnection = OpenConnectionForSchemaExport())
297+
SchemaExport.Create(OutputDdl, true, optionalConnection);
298+
}
299+
300+
protected virtual void DropSchema()
301+
{
302+
DropSchema(OutputDdl, SchemaExport, Sfi, OpenConnectionForSchemaExport);
303+
}
304+
305+
private static void FbCleanUp(ISessionFactoryImplementor sfi)
306+
{
307+
if (sfi?.ConnectionProvider.Driver is FirebirdClientDriver fbDriver)
296308
{
297309
// Firebird will pool each connection created during the test and will marked as used any table
298310
// referenced by queries. It will at best delays those tables drop until connections are actually
@@ -302,20 +314,13 @@ protected virtual void CreateSchema()
302314
// Moved from NH1908 test case, contributed by Amro El-Fakharany.
303315
fbDriver.ClearPool(null);
304316
}
305-
306-
using (var optionalConnection = OpenConnectionForSchemaExport())
307-
SchemaExport.Create(OutputDdl, true, optionalConnection);
308-
}
309-
310-
protected virtual void DropSchema()
311-
{
312-
DropSchema(OutputDdl, SchemaExport, Sfi, OpenConnectionForSchemaExport);
313317
}
314318

315319
public static void DropSchema(bool useStdOut, SchemaExport export, ISessionFactoryImplementor sfi, Func<DbConnection> getConnection = null)
316320
{
317321
using(var optionalConnection = getConnection?.Invoke())
318322
export.Drop(useStdOut, true, optionalConnection);
323+
FbCleanUp(sfi);
319324
}
320325

321326
/// <summary>

src/NHibernate/Driver/FirebirdClientDriver.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,8 @@ public void ClearPool(string connectionString)
160160
using (var clearConnection = CreateConnection())
161161
{
162162
var connectionType = clearConnection.GetType();
163-
_clearPool = connectionType.GetMethod("ClearPool") ?? throw new InvalidOperationException("Unable to resolve ClearPool method.");
164-
_clearAllPools = connectionType.GetMethod("ClearAllPools") ?? throw new InvalidOperationException("Unable to resolve ClearAllPools method.");
163+
_clearPool = connectionType.GetMethod("ClearPool", new[] { connectionType }) ?? throw new InvalidOperationException("Unable to resolve ClearPool method.");
164+
_clearAllPools = connectionType.GetMethod("ClearAllPools", Array.Empty<System.Type>()) ?? throw new InvalidOperationException("Unable to resolve ClearAllPools method.");
165165
}
166166
}
167167

0 commit comments

Comments
 (0)