mirror of https://github.com/django/django.git
Fixed #28210 -- Fixed Model._state.adding on MTI parent model after saving child model.
Regression in 38575b007a
.
This commit is contained in:
parent
99df304c85
commit
59ab1b2683
|
@ -272,6 +272,7 @@ class ForwardOneToOneDescriptor(ForwardManyToOneDescriptor):
|
||||||
if not any(field in fields for field in deferred):
|
if not any(field in fields for field in deferred):
|
||||||
kwargs = {field: getattr(instance, field) for field in fields}
|
kwargs = {field: getattr(instance, field) for field in fields}
|
||||||
obj = rel_model(**kwargs)
|
obj = rel_model(**kwargs)
|
||||||
|
obj._state.adding = instance._state.adding
|
||||||
obj._state.db = instance._state.db
|
obj._state.db = instance._state.db
|
||||||
return obj
|
return obj
|
||||||
return super().get_object(instance)
|
return super().get_object(instance)
|
||||||
|
|
|
@ -25,3 +25,7 @@ Bugfixes
|
||||||
backends don't accept a positional ``request`` argument (:ticket:`28207`).
|
backends don't accept a positional ``request`` argument (:ticket:`28207`).
|
||||||
|
|
||||||
* Fixed introspection of index field ordering on PostgreSQL (:ticket:`28197`).
|
* Fixed introspection of index field ordering on PostgreSQL (:ticket:`28197`).
|
||||||
|
|
||||||
|
* Fixed a regression where ``Model._state.adding`` wasn't set correctly on
|
||||||
|
multi-table inheritance parent models after saving a child model
|
||||||
|
(:ticket:`28210`).
|
||||||
|
|
|
@ -478,8 +478,9 @@ class ModelInheritanceTest(TestCase):
|
||||||
# The mismatch between Restaurant and Place is intentional (#28175).
|
# The mismatch between Restaurant and Place is intentional (#28175).
|
||||||
self.assertSequenceEqual(Supplier.objects.filter(restaurant__in=Place.objects.all()), [s])
|
self.assertSequenceEqual(Supplier.objects.filter(restaurant__in=Place.objects.all()), [s])
|
||||||
|
|
||||||
def test_ptr_accessor_assigns_db(self):
|
def test_ptr_accessor_assigns_state(self):
|
||||||
r = Restaurant.objects.create()
|
r = Restaurant.objects.create()
|
||||||
|
self.assertIs(r.place_ptr._state.adding, False)
|
||||||
self.assertEqual(r.place_ptr._state.db, 'default')
|
self.assertEqual(r.place_ptr._state.db, 'default')
|
||||||
|
|
||||||
def test_related_filtering_query_efficiency_ticket_15844(self):
|
def test_related_filtering_query_efficiency_ticket_15844(self):
|
||||||
|
|
Loading…
Reference in New Issue