diff options
| author | sarahboyce <sarahvboyce95@gmail.com> | 2023-01-14 14:36:23 +0100 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2023-01-16 08:26:34 +0100 |
| commit | 05bcd5baafc0a5783923e32d2b7e2b7fff7d152a (patch) | |
| tree | a3e6d271c2a546bc08b2535690b873932f07e1d2 /tests/expressions | |
| parent | 4b7016866a80ec8582f55fc7eedfa692039e9648 (diff) | |
Refs #30129 -- Added test for create() with F() expression in Subquery.
Fixed in 35431298226165986ad07e91f9d3aca721ff38ec.
Diffstat (limited to 'tests/expressions')
| -rw-r--r-- | tests/expressions/tests.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/expressions/tests.py b/tests/expressions/tests.py index 465edc54b5..7db6013819 100644 --- a/tests/expressions/tests.py +++ b/tests/expressions/tests.py @@ -776,6 +776,24 @@ class BasicExpressionsTests(TestCase): # contain nested aggregates. self.assertNotIn("GROUP BY", sql) + def test_object_create_with_f_expression_in_subquery(self): + Company.objects.create( + name="Big company", num_employees=100000, num_chairs=1, ceo=self.max + ) + biggest_company = Company.objects.create( + name="Biggest company", + num_chairs=1, + ceo=self.max, + num_employees=Subquery( + Company.objects.order_by("-num_employees") + .annotate(max_num_employees=Max("num_employees")) + .annotate(new_num_employees=F("max_num_employees") + 1) + .values("new_num_employees")[:1] + ), + ) + biggest_company.refresh_from_db() + self.assertEqual(biggest_company.num_employees, 100001) + @skipUnlessDBFeature("supports_over_clause") def test_aggregate_rawsql_annotation(self): with self.assertNumQueries(1) as ctx: |
