efcore icon indicating copy to clipboard operation
efcore copied to clipboard

Make sort order consistent in split queries

Open ascott18 opened this issue 1 year ago • 0 comments

Make sort order consistent in split queries between the parent query and its occurrences in subqueries for collection includes.

  • Deterministic sorting was already being added to the parent query (sorting by the identifiers used to join the subquery to the subsequent collection queries). However, due to what appears to be a simple oversight, these were not getting applied to the subquery in the split collection query.
  • Tests that previously expected a thrown exception (Include_collection_skip_take_no_order_by, Include_collection_skip_no_order_by) due to this missing sort order in skip/take queries have been made non-throwing since the same ordering from the parent query is now applied to the subquery that lacked sorting.

All the changes in the tests that add or change an ORDER BY are such that the change makes the subquery exactly match the parent query.

Since the same deterministic sorting was already being appended to the parent query, I didn't go down the paths discussed in #26808 of checking whether existing sorts on the query are already perfectly deterministic.

Fixes #26808

(Apologies for not asking for permission to work on this first - this started out as an exploration of whether I could even figure out how to approach fixing an issue like this).

ascott18 avatar Jun 26 '24 21:06 ascott18