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)
| 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 | """ |
no outgoing calls
no test coverage detected