MCPcopy
hub / github.com/django/django / test_order_by_override

Method test_order_by_override

tests/ordering/tests.py:113–137  ·  view source on GitHub ↗

Only the last order_by has any effect (since they each override any previous ordering).

(self)

Source from the content-addressed store, hash-verified

111 list(Article.objects.order_by("author__unknown_field"))
112
113 def test_order_by_override(self):
114 """
115 Only the last order_by has any effect (since they each override any
116 previous ordering).
117 """
118 self.assertQuerySetEqual(
119 Article.objects.order_by("id"),
120 [
121 "Article 1",
122 "Article 2",
123 "Article 3",
124 "Article 4",
125 ],
126 attrgetter("headline"),
127 )
128 self.assertQuerySetEqual(
129 Article.objects.order_by("id").order_by("-headline"),
130 [
131 "Article 4",
132 "Article 3",
133 "Article 2",
134 "Article 1",
135 ],
136 attrgetter("headline"),
137 )
138
139 def test_order_by_nulls_first_and_last(self):
140 msg = "nulls_first and nulls_last are mutually exclusive"

Callers

nothing calls this directly

Calls 2

assertQuerySetEqualMethod · 0.80
order_byMethod · 0.80

Tested by

no test coverage detected