MCPcopy
hub / github.com/django/django / test_nested_function_ordering

Method test_nested_function_ordering

tests/db_functions/tests.py:15–37  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

13
14class FunctionTests(TestCase):
15 def test_nested_function_ordering(self):
16 Author.objects.create(name="John Smith")
17 Author.objects.create(name="Rhonda Simpson", alias="ronny")
18
19 authors = Author.objects.order_by(Length(Coalesce("alias", "name")))
20 self.assertQuerySetEqual(
21 authors,
22 [
23 "Rhonda Simpson",
24 "John Smith",
25 ],
26 lambda a: a.name,
27 )
28
29 authors = Author.objects.order_by(Length(Coalesce("alias", "name")).desc())
30 self.assertQuerySetEqual(
31 authors,
32 [
33 "John Smith",
34 "Rhonda Simpson",
35 ],
36 lambda a: a.name,
37 )
38
39 def test_func_transform_bilateral(self):
40 with register_lookup(CharField, UpperBilateral):

Callers

nothing calls this directly

Calls 6

LengthClass · 0.90
CoalesceClass · 0.90
order_byMethod · 0.80
assertQuerySetEqualMethod · 0.80
createMethod · 0.45
descMethod · 0.45

Tested by

no test coverage detected