Skip to content

Commit d2f6f3e

Browse files
Add a test for generated keys with constants only in where.
1 parent 60c5213 commit d2f6f3e

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
using System.Collections.Generic;
1212
using System.Linq;
1313
using NHibernate.DomainModel.Northwind.Entities;
14+
using NHibernate.Linq.Visitors;
1415
using NUnit.Framework;
1516
using NHibernate.Linq;
1617

src/NHibernate.Test/Linq/ConstantTest.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System.Collections.Generic;
22
using System.Linq;
33
using NHibernate.DomainModel.Northwind.Entities;
4+
using NHibernate.Linq.Visitors;
45
using NUnit.Framework;
56

67
namespace NHibernate.Test.Linq
@@ -205,5 +206,24 @@ public void ConstantsInFuncCall()
205206
Assert.That(v1, Is.EqualTo(1), "v1");
206207
Assert.That(v2, Is.EqualTo(2), "v2");
207208
}
209+
210+
[Test]
211+
public void ConstantInWhereDoesNotCauseManyKeys()
212+
{
213+
var q1 = (from c in db.Customers
214+
where c.CustomerId == "ALFKI"
215+
select c);
216+
var q2 = (from c in db.Customers
217+
where c.CustomerId == "ANATR"
218+
select c);
219+
var parameters1 = ExpressionParameterVisitor.Visit(q1.Expression, Sfi);
220+
var k1 = ExpressionKeyVisitor.Visit(q1.Expression, parameters1);
221+
var parameters2 = ExpressionParameterVisitor.Visit(q2.Expression, Sfi);
222+
var k2 = ExpressionKeyVisitor.Visit(q2.Expression, parameters2);
223+
224+
Assert.That(parameters1, Has.Count.GreaterThan(0), "parameters1");
225+
Assert.That(parameters2, Has.Count.GreaterThan(0), "parameters2");
226+
Assert.That(k2, Is.EqualTo(k1));
227+
}
208228
}
209229
}

0 commit comments

Comments
 (0)