Opened 6 years ago

Last modified 6 years ago

#29447 closed Bug

RelatedManager.set() doesn't pass bulk keyword argument to clear() — at Initial Version

Reported by: Jeremy Lainé Owned by: nobody
Component: Database layer (models, ORM) Version: 2.0
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

For reverse many-to-one relations, the set method's bulk keyword argument is passed down to the add() and remove() methods. It isn't however passed down to the clear() method:

https://github.com/django/django/blob/265506bbc347a6b3fcc6c66ab1a2417b3b7ea57a/django/db/models/fields/related_descriptors.py#L711

This looks like a bug, as passing bulk=True, clear=True results in the following behavior:

  • clear() is invoked in "non-bulk" mode, triggering signals
  • add() is correctly invoked in "bulk" mode, no signals are not triggered

I spotted this while reading the related_descriptors.py code to fix #29440.

Change History (0)

Note: See TracTickets for help on using tickets.
Back to Top