Skip to content

Fix #6545 sorting variables for expression object sort fields#9250

Merged
michaelstaib merged 4 commits into
mainfrom
mst/issue-6545
Jul 10, 2026
Merged

Fix #6545 sorting variables for expression object sort fields#9250
michaelstaib merged 4 commits into
mainfrom
mst/issue-6545

Conversation

@michaelstaib

@michaelstaib michaelstaib commented Feb 27, 2026

Copy link
Copy Markdown
Member
  • add a regression test for sorting via variables on a custom expression sort field returning an object type without a default constructor
  • avoid assigning the expression return CLR type as the input field runtime type in sorting descriptors
  • preserve sorting expression runtime metadata by deriving SortField.RuntimeType from the expression return type

Fixes #6545
Closes #6660

@michaelstaib michaelstaib added the 🔍 investigate Indicates that an issue or pull request needs more information. label Mar 5, 2026
@codecov

codecov Bot commented Mar 5, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 0.00%. Comparing base (84e5c32) to head (a5ba417).
⚠️ Report is 54 commits behind head on main.

Additional details and impacted files
@@     Coverage Diff      @@
##   main   #9250   +/-   ##
============================
============================

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copilot AI review requested due to automatic review settings April 8, 2026 12:32

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.RuntimeType from an expression’s CLR return type to avoid incorrect variable parsing behavior.
  • Preserved sorting runtime metadata by deriving SortField.RuntimeType from 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.

@ChilliCream ChilliCream deleted a comment from github-actions Bot Apr 8, 2026
# Conflicts:
#	src/HotChocolate/Data/src/Data/Sorting/Fields/SortField.cs
@michaelstaib
michaelstaib merged commit bf847d2 into main Jul 10, 2026
144 of 146 checks passed
@michaelstaib
michaelstaib deleted the mst/issue-6545 branch July 10, 2026 11:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🌶️ hot chocolate 🔍 investigate Indicates that an issue or pull request needs more information.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sort with Variables tries to instantiate an object from the target collection, fails if no parameterless constructor available

2 participants