我正在尝试使这个事务 mysql 兼容。由于mysql不允许当前操作。MySQL 不允许更新您已经在内部选择中使用的表作为更新条件。
收到此错误
django.db.utils.OperationalError: (1093, "You can't specify target table 'catalogue_category' for update in FROM clause")
代码:
included_in_non_public_subtree = self.__class__.objects.filter(
is_public=False, path__rstartswith=OuterRef("path"), depth__lt=OuterRef("depth")
)
self.get_descendants_and_self().update(
ancestors_are_public=Exists(
included_in_non_public_subtree.values("id"), negated=True)
)
https://github.com/django-oscar/django-oscar/pull/3050#pullrequestreview-461576714