Fix #6545 sorting variables for expression object sort fields#9250
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #9250 +/- ##
============================
============================
☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR fixes a variable-coercion failure when sorting via variables on a custom expression-based sort field that returns an object type without a parameterless constructor (issue #6545). It ensures the input parsing runtime type is not incorrectly set to the expression’s CLR return type while still preserving the expression runtime metadata needed by the sorting pipeline.
Changes:
- Added a regression test reproducing sorting-by-variable on an expression sort field returning a non-default-constructible object.
- Stopped assigning
SortFieldConfiguration.RuntimeTypefrom an expression’s CLR return type to avoid incorrect variable parsing behavior. - Preserved sorting runtime metadata by deriving
SortField.RuntimeTypefrom the expression return type during type completion.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/HotChocolate/Data/test/Data.Sorting.InMemory.Tests/Issue6545ReproTests.cs | Adds regression coverage for sorting with variables on an expression sort field returning an object without a default ctor. |
| src/HotChocolate/Data/src/Data/Sorting/SortFieldDescriptor.cs | Prevents expression return CLR type from being used as the input-field runtime type in the descriptor configuration. |
| src/HotChocolate/Data/src/Data/Sorting/Fields/SortField.cs | Restores expression return-type runtime metadata at the SortField level for sorting execution while keeping input parsing safe. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
# Conflicts: # src/HotChocolate/Data/src/Data/Sorting/Fields/SortField.cs
Fixes #6545
Closes #6660