diff options
| author | Michal Mládek <osvc.04923031@gmail.com> | 2025-05-26 18:37:34 +0200 |
|---|---|---|
| committer | Jacob Walls <jacobtylerwalls@gmail.com> | 2025-10-27 15:11:19 -0400 |
| commit | ea3a71c2d09f8281d8a50ed20e40e1fb13db5cd9 (patch) | |
| tree | 44d5fec067e6bb769875692c988efde12b333e17 /django/db/models/sql/query.py | |
| parent | 0ea01101c3a35568bc43e9707ac058b9874bd425 (diff) | |
Fixed #26434 -- Removed faulty clearing of ordering field when missing from explicit grouping.
Co-authored-by: Simon Charette <charette.s@gmail.com>
Diffstat (limited to 'django/db/models/sql/query.py')
| -rw-r--r-- | django/db/models/sql/query.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py index 84950d4ec0..8f9349e7eb 100644 --- a/django/db/models/sql/query.py +++ b/django/db/models/sql/query.py @@ -2346,7 +2346,13 @@ class Query(BaseExpression): query (not even the model's default). """ if not force and ( - self.is_sliced or self.distinct_fields or self.select_for_update + self.is_sliced + or self.distinct_fields + or self.select_for_update + or ( + isinstance(self.group_by, tuple) + and not {*self.order_by, *self.extra_order_by}.issubset(self.group_by) + ) ): return self.order_by = () |
