Ticket #34634 : Creating objects with nested MTI crashes

33 views
Skip to first unread message

Akash Sen

unread,
Jun 7, 2023, 10:55:28 PM6/7/23
to Django developers (Contributions to Django itself)
Ticket : https://code.djangoproject.com/ticket/34634

Possible reason behind the bug:

  • The local OneToOneField of place_ptr inside ItalianRestaurantManyParents is being inherited from the place_ptr field of Restaurant. Which is one of the ancestor of the current model.
  • That successfully inserts the model Place while calling _save_parents() for Restaurant inside the recursion tree.
  • So the local field of place_ptr does not have an attribute with name attname.

Possible fix :

  • When fetching the immediate parents inside the _save_parents() method, eliminate the ones which have a subclass inside that list. As they willbe called again when we insert their subclass.

Problem with the fix:
Not being able to reproduce the behavior of the failed test in Local with postgresql and sqlite3 database. All the assertions are passing there.

Traceback (most recent call last): File "/home/jenkins/workspace/pull-requests-focal/database/mysql/label/focal-pr/python/python3.11/tests/model_inheritance/tests.py", line 169, in test_create_diamond_mti_common_parents self.assertEqual(itrmp.name, "Ristorante Miron") AssertionError: '' != 'Ristorante Miron' + Ristorante Miron

Reply all
Reply to author
Forward
0 new messages