Add a missing short circuit in query parameter expansion. #1548
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
As explained in #1547 first commit rationals, queries having a list parameter need some additional processing once its value is known. This parameter (having a list value) may need to be removed in case of empty list, or replaced by a list of parameters representing one value of the list each.
But when the list has only one value, the parameter is not replaced but just retyped to the list element type, with its value changed from the list to the single value. In such case the query is not changed.
This was already rightfully short-circuited for
AbstractQueryImpl
, by yielding back the same query string. But forExpressionQueryImpl
(used by LINQ queries), a newIQueryExpression
was computed anyway, while being in fine identical to the original one. (Its type excepted, leading to NH-3050: you can check its test cases, they use on purpose a single value list parameter, otherwise they could not reproduce the trouble.)So here an additional short-circuit has been added to just yield the original query in this case. (NH-3050 test cases do indeed test this change by the way.)
NH-3050 original solution could be reverted with this change, but on its principles its solution stays also valid (it does include query expression type in the plan key). So better leave it in place.