Skip to content

Commit 158a75a

Browse files
committed
Move clear pool to CreateSchema
1 parent 9223c67 commit 158a75a

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

src/NHibernate.Test/TestCase.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,17 @@ protected virtual void AddMappings(Configuration configuration)
292292

293293
protected virtual void CreateSchema()
294294
{
295+
if (Sfi?.ConnectionProvider.Driver is FirebirdClientDriver fbDriver)
296+
{
297+
// Firebird will pool each connection created during the test and will marked as used any table
298+
// referenced by queries. It will at best delays those tables drop until connections are actually
299+
// closed, or immediately fail dropping them.
300+
// This results in other tests failing when they try to create tables with same name.
301+
// By clearing the connection pool the tables will get dropped. This is done by the following code.
302+
// Moved from NH1908 test case, contributed by Amro El-Fakharany.
303+
fbDriver.ClearPool(null);
304+
}
305+
295306
using (var optionalConnection = OpenConnectionForSchemaExport())
296307
SchemaExport.Create(OutputDdl, true, optionalConnection);
297308
}
@@ -303,17 +314,6 @@ protected virtual void DropSchema()
303314

304315
public static void DropSchema(bool useStdOut, SchemaExport export, ISessionFactoryImplementor sfi, Func<DbConnection> getConnection = null)
305316
{
306-
if (sfi?.ConnectionProvider.Driver is FirebirdClientDriver fbDriver)
307-
{
308-
// Firebird will pool each connection created during the test and will marked as used any table
309-
// referenced by queries. It will at best delays those tables drop until connections are actually
310-
// closed, or immediately fail dropping them.
311-
// This results in other tests failing when they try to create tables with same name.
312-
// By clearing the connection pool the tables will get dropped. This is done by the following code.
313-
// Moved from NH1908 test case, contributed by Amro El-Fakharany.
314-
fbDriver.ClearPool(null);
315-
}
316-
317317
using(var optionalConnection = getConnection?.Invoke())
318318
export.Drop(useStdOut, true, optionalConnection);
319319
}

0 commit comments

Comments
 (0)