Skip to content

Commit 3441fb3

Browse files
committed
Failing test
1 parent f7b64c5 commit 3441fb3

File tree

2 files changed

+42
-1
lines changed

2 files changed

+42
-1
lines changed

src/NHibernate.Test/Async/Linq/ConstantTest.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,13 @@
1111
using System.Collections.Generic;
1212
using System.Linq;
1313
using System.Reflection;
14+
using NHibernate.Criterion;
1415
using NHibernate.DomainModel.Northwind.Entities;
1516
using NHibernate.Engine.Query;
17+
using NHibernate.Linq;
1618
using NHibernate.Linq.Visitors;
1719
using NHibernate.Util;
1820
using NUnit.Framework;
19-
using NHibernate.Linq;
2021

2122
namespace NHibernate.Test.Linq
2223
{

src/NHibernate.Test/Linq/ConstantTest.cs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
using System.Collections.Generic;
22
using System.Linq;
33
using System.Reflection;
4+
using NHibernate.Criterion;
45
using NHibernate.DomainModel.Northwind.Entities;
56
using NHibernate.Engine.Query;
7+
using NHibernate.Linq;
68
using NHibernate.Linq.Visitors;
79
using NHibernate.Util;
810
using NUnit.Framework;
@@ -257,6 +259,44 @@ public void PlansAreCached()
257259
}
258260
}
259261

262+
//GH-2298 - Different Update queries - same query cache plan
263+
[Test]
264+
public void DmlPlansAreProperlyHandled()
265+
{
266+
var queryPlanCacheType = typeof(QueryPlanCache);
267+
268+
var cache = (SoftLimitMRUCache)
269+
queryPlanCacheType
270+
.GetField("planCache", BindingFlags.Instance | BindingFlags.NonPublic)
271+
.GetValue(Sfi.QueryPlanCache);
272+
cache.Clear();
273+
274+
using (session.BeginTransaction())
275+
{
276+
using (var spy = new SqlLogSpy())
277+
{
278+
var listOfGuids = new[] {"UNKNOWN", "UNKNOWN2"}.ToList();
279+
db.Customers.Where(x => listOfGuids.Contains(x.CustomerId)).Update(
280+
x => new Customer
281+
{
282+
CompanyName = "Constant1"
283+
});
284+
285+
db.Customers.Where(x => listOfGuids.Contains(x.CustomerId))
286+
.Update(
287+
x => new Customer
288+
{
289+
ContactName = "Constant1"
290+
});
291+
292+
Assert.That(
293+
cache.Count,
294+
Is.EqualTo(0).Or.EqualTo(2),
295+
"Query plans should either be cached separately or not cached at all.");
296+
}
297+
}
298+
}
299+
260300
[Test]
261301
public void PlansWithNonParameterizedConstantsAreNotCached()
262302
{

0 commit comments

Comments
 (0)