Skip to content

Commit 4f1ed53

Browse files
committed
Skip delete query if no polymorphic entities
1 parent e50e472 commit 4f1ed53

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/NHibernate.Test/TestCase.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.Collections.Generic;
44
using System.Data;
55
using System.Data.Common;
6+
using System.Linq;
67
using System.Reflection;
78
using log4net;
89
using NHibernate.Cfg;
@@ -230,13 +231,20 @@ private string GetCombinedFailureMessage(TestContext.ResultAdapter result, strin
230231

231232
protected virtual bool CheckDatabaseWasCleaned()
232233
{
233-
if (Sfi.GetAllClassMetadata().Count == 0)
234+
var allClassMetadata = Sfi.GetAllClassMetadata();
235+
if (allClassMetadata.Count == 0)
234236
{
235237
// Return early in the case of no mappings, also avoiding
236238
// a warning when executing the HQL below.
237239
return true;
238240
}
239241

242+
var explicitPolymorphismEntities = allClassMetadata.Values.Where(x => x is NHibernate.Persister.Entity.IQueryable queryable && queryable.IsExplicitPolymorphism).ToArray();
243+
244+
//TODO: Maybe add explicit load query checks
245+
if (explicitPolymorphismEntities.Length == allClassMetadata.Count)
246+
return true;
247+
240248
bool empty;
241249
using (ISession s = OpenSession())
242250
{

0 commit comments

Comments
 (0)