Hi guys,
I am trying to figure out something nasty in the linq provider.
Take a look at the following queries:
this.count = 1;
> var foos1 = session.Query<Foo>()
> .Where(x => x.Name == "Banana")
> .Select(x => new
> {
> x.Name,
> count,
> User = "abc"
> }).First();
> this.count = 2;
> var foos2 = session.Query<Foo>()
> .Where(x => x.Name == "Egg")
> .Select(x => new
> {
> x.Name,
> count,
> User = "def"
> }).First();
Right now, because we are caching the HQL plans, we are also caching the
_constant values_.
That is, The result of foos2 would be count = 1 (and not 2) and User =
"abc" (and not "def")
I pushed a failing test here:
https://github.com/nhibernate/nhibernate-core/tree/nh-2500
I am pretty sure that the actual reason for the error is that we are
caching the lambdas. In other words, the HQL Query Plan is reusing the
first lambda, instead of invoking the second one.
I have modified the way we are caching query plans to take that into
account. The way I do that is to check whatever we are inside a select
clause, and if we are, to treat the constants there are real constants, and
not as parameter constants for the purpose of generating the query plan key.
All tests are passing, but I would still like to have a second pair of eyes
on that.