Skip to content

Commit 53d81e3

Browse files
Fix a wrong parameter value for query translation
It was not having any impact because concrete used implementations are currently not using its value.
1 parent f3b1207 commit 53d81e3

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

src/NHibernate/Async/Impl/ExpressionQueryImpl.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
//------------------------------------------------------------------------------
99

1010

11-
using System;
1211
using System.Collections;
1312
using System.Collections.Generic;
1413
using System.Linq;
@@ -26,7 +25,7 @@ namespace NHibernate.Impl
2625
using System.Threading.Tasks;
2726
using System.Threading;
2827

29-
partial class ExpressionFilterImpl : ExpressionQueryImpl
28+
internal partial class ExpressionFilterImpl : ExpressionQueryImpl
3029
{
3130

3231
public override async Task<IList> ListAsync(CancellationToken cancellationToken = default(CancellationToken))

src/NHibernate/Impl/ExpressionQueryImpl.cs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
using System;
21
using System.Collections;
32
using System.Collections.Generic;
43
using System.Linq;
@@ -21,8 +20,17 @@ public ExpressionQueryImpl(IQueryExpression queryExpression, ISessionImplementor
2120
QueryExpression = queryExpression;
2221
}
2322

23+
protected ExpressionQueryImpl(
24+
IQueryExpression queryExpression, ISessionImplementor session, ParameterMetadata parameterMetadata, bool isFilter)
25+
: this(queryExpression, session, parameterMetadata)
26+
{
27+
_isFilter = isFilter;
28+
}
29+
2430
public IQueryExpression QueryExpression { get; private set; }
2531

32+
protected readonly bool _isFilter;
33+
2634
/// <summary>
2735
/// Warning: adds new parameters to the argument by side-effect, as well as mutating the query expression tree!
2836
/// </summary>
@@ -75,10 +83,8 @@ protected override IQueryExpression ExpandParameters(IDictionary<string, TypedVa
7583

7684
//TODO: Do we need to translate expression one more time here?
7785
// This is not much an issue anymore: ExpressionQueryImpl are currently created only with NhLinqExpression
78-
// which do cache their translation. By the way, the false transmitted below as filter parameter to
79-
// Translate is wrong, since this ExpandParameters may also be called from ExpressionFilterImpl.
80-
// But that does not matter for NhLinqExpression.
81-
var newTree = ParameterExpander.Expand(QueryExpression.Translate(Session.Factory, false), map);
86+
// which do cache their translation.
87+
var newTree = ParameterExpander.Expand(QueryExpression.Translate(Session.Factory, _isFilter), map);
8288
var key = new StringBuilder(QueryExpression.Key);
8389

8490
foreach (var pair in map)
@@ -94,12 +100,12 @@ protected override IQueryExpression ExpandParameters(IDictionary<string, TypedVa
94100
}
95101
}
96102

97-
partial class ExpressionFilterImpl : ExpressionQueryImpl
103+
internal partial class ExpressionFilterImpl : ExpressionQueryImpl
98104
{
99105
private readonly object collection;
100106

101107
public ExpressionFilterImpl(IQueryExpression queryExpression, object collection, ISessionImplementor session, ParameterMetadata parameterMetadata)
102-
: base(queryExpression, session, parameterMetadata)
108+
: base(queryExpression, session, parameterMetadata, true)
103109
{
104110
this.collection = collection;
105111
}

0 commit comments

Comments
 (0)