Opened 3 years ago

Closed 3 years ago

#29447 closed Bug (fixed)

RelatedManager.set() doesn't pass bulk keyword argument to clear()

Reported by: Jeremy Lainé Owned by: Alexandr Tatarinov
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 (last modified by Jeremy Lainé)

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:

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

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

Admitedly, I'm not too sure why you would want to do this, but at the very least the docs should mention if this combination is unsupported.

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

Change History (6)

comment:1 Changed 3 years ago by Jeremy Lainé

Description: modified (diff)

comment:2 Changed 3 years ago by Alexandr Tatarinov

I would like to work on this if confirmed as bug. Seems pretty straightforward to fix. Also I think we should add some tests to check number of queries issued.

comment:3 Changed 3 years ago by Tim Graham

Triage Stage: UnreviewedAccepted

comment:4 Changed 3 years ago by Alexandr Tatarinov

Owner: changed from nobody to Alexandr Tatarinov
Status: newassigned

comment:5 Changed 3 years ago by Alexandr Tatarinov

Has patch: set

comment:6 Changed 3 years ago by Tim Graham <timograham@…>

Resolution: fixed
Status: assignedclosed

In 74106185:

Fixed #29447 -- Made RelatedManager.set() pass bulk argument to clear().

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