Opened 5 years ago
Last modified 5 years ago
#31246 closed Bug
Related Model with inheritance generates wrong select_for_update 'of' — at Initial Version
Description ¶
Consider the following models:
class A(models.Model): field1 = models.IntegerField() class B(A): field2 = models.IntegerField() class C(models.Model): b = models.ForeignKey(B, on_delete=models.CASCADE)
queryset = C.objects.select_related('b').select_for_update(of=('b'))
The above queryet generates the following query:
SELECT "selectforupdate_c"."id", "selectforupdate_c"."b_id", "selectforupdate_a"."id", "selectforupdate_a"."field1", "selectforupdate_b"."a_ptr_id", "selectforupdate_b"."field2" FROM "selectforupdate_c" INNER JOIN "selectforupdate_b" ON ( "selectforupdate_c"."b_id" = "selectforupdate_b"."a_ptr_id" ) INNER JOIN "selectforupdate_a" ON ( "selectforupdate_b"."a_ptr_id" = "selectforupdate_a"."id" ) FOR UPDATE OF "selectforupdate_a"
The of
clause in the generated SQL references the model a
instead of b
Note:
See TracTickets
for help on using tickets.