I don't think your issue has anything to do with proxy models.
You'll get the exact same error if your use Parent.objects instead of Child.objects as both will generate the same SQL:
SELECT *
FROM parent
LEFT JOIN foreign ON parent.foreign_id = foreign.id
FOR UPDATE OF parent
In this case "parent" cannot be selected for update since it's "foreign_id" column, which is "nullable", is implied in an outer join.
PostgreSQL simply doesn't support that and you'll have to rethink your data model if this is something you need to achieve[0]
Cheers,
Simon
[0] https://www.postgresql.org/message-id/21634.1160151923@sss.pgh.pa.us
Le mercredi 23 septembre 2020 à 12:15:35 UTC-4, d.ivan...@distillery.com a écrit :
Hello.I just wanted to know, whether I run into a bug, and whether I should report it.Normally select_for_update and select_related try to lock all affected rows in all tables. One can specify "of" for select_for_update to limit tables to lock (to prevent locking nullable relations).Recently a bug was fixed, which allowed to lock parent nodes with multitable inheritance. But what about proxies? For me the following does not work. Should it?class Parent(Model):foreign = ForeignKey(Foreign, null=True, blank=True)class Child(Parent):class Meta:proxy = Trueclass Foreign(Model):passwith transaction.atomic():Child.objects.select_for_update(of=('self',)).select_related('foreign').get(pk=1)So the (pseudo) code above fails with a message "FOR UPDATE cannot be applied to the nullable side of an outer join"So is this expected behaviour or a bug? What are possible workarounds for that?
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/b9e15c75-8ec7-4ca2-a9a9-21f0d58f64a3n%40googlegroups.com.
No comments:
Post a Comment