MCPcopy
hub / github.com/django/django / test_order_by_multiline_sql

Method test_order_by_multiline_sql

tests/expressions/tests.py:593–620  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

591 self.assertSequenceEqual(mustermanns_by_seniority, [self.max, mary])
592
593 def test_order_by_multiline_sql(self):
594 raw_order_by = (
595 RawSQL(
596 """
597 CASE WHEN num_employees > 1000
598 THEN num_chairs
599 ELSE 0 END
600 """,
601 [],
602 ).desc(),
603 RawSQL(
604 """
605 CASE WHEN num_chairs > 1
606 THEN 1
607 ELSE 0 END
608 """,
609 [],
610 ).asc(),
611 )
612 for qs in (
613 Company.objects.all(),
614 Company.objects.distinct(),
615 ):
616 with self.subTest(qs=qs):
617 self.assertSequenceEqual(
618 qs.order_by(*raw_order_by),
619 [self.example_inc, self.gmbh, self.foobar_ltd],
620 )
621
622 def test_outerref(self):
623 inner = Company.objects.filter(point_of_contact=OuterRef("pk"))

Callers

nothing calls this directly

Calls 6

RawSQLClass · 0.90
distinctMethod · 0.80
order_byMethod · 0.80
descMethod · 0.45
ascMethod · 0.45
allMethod · 0.45

Tested by

no test coverage detected