Fixed #30796 -- Prevented select_related() from mutating a queryset on chaining.

Thanks Darren Maki for the report.
This commit is contained in:
Simon Charette 2019-09-23 15:51:43 -04:00 committed by Mariusz Felisiak
parent e8ad265ac8
commit 37f8f29377
2 changed files with 12 additions and 0 deletions

View file

@ -106,3 +106,10 @@ class TestQuery(SimpleTestCase):
self.assertIsInstance(b_isnull, RelatedIsNull)
self.assertIsInstance(b_isnull.lhs, SimpleCol)
self.assertEqual(b_isnull.lhs.target, ObjectC._meta.get_field('objectb'))
def test_clone_select_related(self):
query = Query(Item)
query.add_select_related(['creator'])
clone = query.clone()
clone.add_select_related(['note', 'creator__extra'])
self.assertEqual(query.select_related, {'creator': {}})