Changes between Initial Version and Version 1 of Ticket #37097, comment 2


Ignore:
Timestamp:
May 12, 2026, 2:11:00 PM (83 minutes ago)
Author:
Jacob Walls

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #37097, comment 2

    initial v1  
    4949Two options come to mind:
    5050
    51 **Option 1: take a lighter touch when setting default ordering:**
    52 {{{#!diff
    53 diff --git a/django/db/models/query.py b/django/db/models/query.py
    54 index 6cdd7681b2..9d373410e2 100644
    55 --- a/django/db/models/query.py
    56 +++ b/django/db/models/query.py
    57 @@ -1702,9 +1702,10 @@ class QuerySet(AltersData):
    58          clone = self._chain()
    59          # Clear limits and ordering so they can be reapplied
    60          clone.query.clear_ordering(force=True)
    61 -        clone.query.default_ordering = True
    62          clone.query.clear_limits()
    63          clone.query.combined_queries = (self.query, *(qs.query for qs in other_qs))
    64 +        if not clone.query.combined_queries:
    65 +            clone.query.default_ordering = True
    66          clone.query.combinator = combinator
    67          clone.query.combinator_all = all
    68          return clone
    69 }}}
     51**Option 1: take a lighter touch when setting default ordering after union?** (EDIT: removed incorrect suggested diff.)
    7052
    7153**Option 2: Extend the fix from yesterday's Oracle/SQLite fixes to also clear unnecessary orderings on Postgres:
Back to Top