mirror of
https://github.com/django/django.git
synced 2024-12-23 01:25:58 +00:00
Refs #30129 -- Added test for create() with F() expression in Subquery.
Fixed in 3543129822
.
This commit is contained in:
parent
4b7016866a
commit
05bcd5baaf
@ -776,6 +776,24 @@ class BasicExpressionsTests(TestCase):
|
|||||||
# contain nested aggregates.
|
# contain nested aggregates.
|
||||||
self.assertNotIn("GROUP BY", sql)
|
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")
|
@skipUnlessDBFeature("supports_over_clause")
|
||||||
def test_aggregate_rawsql_annotation(self):
|
def test_aggregate_rawsql_annotation(self):
|
||||||
with self.assertNumQueries(1) as ctx:
|
with self.assertNumQueries(1) as ctx:
|
||||||
|
Loading…
Reference in New Issue
Block a user