Error when filtering or sorting on a field of a related object, where the field isn't a simple property access. #7176
Labels
Area: Data
Issue is related to filtering, sorting, pagination or projections
🐛 bug
Something isn't working
🌶️ hot chocolate
Product
Hot Chocolate
Version
13.8.1
Link to minimal reproduction
https://github.com/darren-clark/graphql-platform/blob/sort_filter_fix/src/HotChocolate/Data/test/Data.Filters.SqlServer.Tests/QueryableFilterVisitorObjectTests.cs#L671
Steps to reproduce
Using EF, add a sort or filter field to an object that flattens a field of a related object.
e.g.
Then on a type that has an object of this type as a field, use this input type:
Query
Baz
with a filter onbar.fooBarString
such asWhat is expected?
SQL generated that filters on Foo.BarString
What is actually happening?
Exception thrown that in
VisitLambda
the replaced expression must be the same type as the original expression.Relevant log output
No response
Additional context
The issue is that it is doing a replace on the whole LambdaExpression, including parameters, then extracting the replaced Body.
This means the replacing expression must be a ParameterExpression, but in this case it is a MemberExpression.
Replacing the original ParameterExpression in the body works fine, and is correct. However replacing it the LamdaExpression.Parameters fails, and is unnecessary since the first thing done with this rewritten expression is to extract the body and discard parameters.
The text was updated successfully, but these errors were encountered: