mirror of
https://github.com/django/django.git
synced 2025-08-04 02:48:35 +00:00
Fixed #29692 -- Fixed removing ordering parts for multiline RawSQL expressions.
This commit is contained in:
parent
ef082ebb84
commit
567b9928a3
2 changed files with 25 additions and 1 deletions
|
@ -384,6 +384,29 @@ class BasicExpressionsTests(TestCase):
|
|||
)
|
||||
self.assertSequenceEqual(mustermanns_by_seniority, [self.max, mary])
|
||||
|
||||
def test_order_by_multiline_sql(self):
|
||||
raw_order_by = (
|
||||
RawSQL('''
|
||||
CASE WHEN num_employees > 1000
|
||||
THEN num_chairs
|
||||
ELSE 0 END
|
||||
''', []).desc(),
|
||||
RawSQL('''
|
||||
CASE WHEN num_chairs > 1
|
||||
THEN 1
|
||||
ELSE 0 END
|
||||
''', []).asc()
|
||||
)
|
||||
for qs in (
|
||||
Company.objects.all(),
|
||||
Company.objects.distinct(),
|
||||
):
|
||||
with self.subTest(qs=qs):
|
||||
self.assertSequenceEqual(
|
||||
qs.order_by(*raw_order_by),
|
||||
[self.example_inc, self.gmbh, self.foobar_ltd],
|
||||
)
|
||||
|
||||
def test_outerref(self):
|
||||
inner = Company.objects.filter(point_of_contact=OuterRef('pk'))
|
||||
msg = (
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue