MCPcopy
hub / github.com/django/django / test_order_by_nulls_last

Method test_order_by_nulls_last

tests/ordering/tests.py:150–179  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

148 self.assertSequenceEqual(queryset.reverse(), list(reversed(sequence)))
149
150 def test_order_by_nulls_last(self):
151 Article.objects.filter(headline="Article 3").update(author=self.author_1)
152 Article.objects.filter(headline="Article 4").update(author=self.author_2)
153 # asc and desc are chainable with nulls_last.
154 self.assertQuerySetEqualReversible(
155 Article.objects.order_by(F("author").desc(nulls_last=True), "headline"),
156 [self.a4, self.a3, self.a1, self.a2],
157 )
158 self.assertQuerySetEqualReversible(
159 Article.objects.order_by(F("author").asc(nulls_last=True), "headline"),
160 [self.a3, self.a4, self.a1, self.a2],
161 )
162 self.assertQuerySetEqualReversible(
163 Article.objects.order_by(
164 Upper("author__name").desc(nulls_last=True), "headline"
165 ),
166 [self.a4, self.a3, self.a1, self.a2],
167 )
168 self.assertQuerySetEqualReversible(
169 Article.objects.order_by(
170 Upper("author__name").asc(nulls_last=True), "headline"
171 ),
172 [self.a3, self.a4, self.a1, self.a2],
173 )
174 self.assertQuerySetEqualReversible(
175 Article.objects.annotate(upper_name=Upper("author__name")).order_by(
176 F("upper_name").asc(nulls_last=True), "headline"
177 ),
178 [self.a3, self.a4, self.a1, self.a2],
179 )
180
181 def test_order_by_nulls_first(self):
182 Article.objects.filter(headline="Article 3").update(author=self.author_1)

Callers

nothing calls this directly

Calls 9

FClass · 0.90
UpperClass · 0.90
order_byMethod · 0.80
annotateMethod · 0.80
updateMethod · 0.45
filterMethod · 0.45
descMethod · 0.45
ascMethod · 0.45

Tested by

no test coverage detected