MCPcopy
hub / github.com/django/django / clear_ordering

Method clear_ordering

django/db/models/sql/query.py:2390–2409  ·  view source on GitHub ↗

Remove any ordering settings if the current query allows it without side effects, set 'force' to True to clear the ordering regardless. If 'clear_default' is True, there will be no ordering in the resulting query (not even the model's default).

(self, force=False, clear_default=True)

Source from the content-addressed store, hash-verified

2388 return order_by_set.issubset(self.group_by)
2389
2390 def clear_ordering(self, force=False, clear_default=True):
2391 """
2392 Remove any ordering settings if the current query allows it without
2393 side effects, set 'force' to True to clear the ordering regardless.
2394 If 'clear_default' is True, there will be no ordering in the resulting
2395 query (not even the model's default).
2396 """
2397 if not force and (
2398 self.is_sliced or self.distinct_fields or self.select_for_update
2399 ):
2400 return
2401 self.order_by = ()
2402 self.extra_order_by = ()
2403 if clear_default:
2404 self.default_ordering = False
2405 # Ordering is cleared on combined queries with clear_default=False
2406 # when union() and analogues are called, so percolate any possible
2407 # clear_default=True.
2408 for query in self.combined_queries:
2409 query.clear_ordering(force=False, clear_default=clear_default)
2410
2411 def set_group_by(self, allow_aliases=True):
2412 """

Callers 13

as_sqlMethod · 0.95
get_prep_lookupMethod · 0.80
_earliestMethod · 0.80
deleteMethod · 0.80
_combinator_queryMethod · 0.80
order_byMethod · 0.80
pre_sql_setupMethod · 0.80
get_aggregationMethod · 0.80
existsMethod · 0.80
split_excludeMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected