[Django] #29447: RelatedManager.set() doesn't pass bulk keyword argument to clear()

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

[Django] #29447: RelatedManager.set() doesn't pass bulk keyword argument to clear()

Django
#29447: RelatedManager.set() doesn't pass bulk keyword argument to clear()
-------------------------------------+-------------------------------------
               Reporter:  Jeremy     |          Owner:  nobody
  Lainé                              |
                   Type:  Bug        |         Status:  new
              Component:  Database   |        Version:  2.0
  layer (models, ORM)                |
               Severity:  Normal     |       Keywords:
           Triage Stage:             |      Has patch:  0
  Unreviewed                         |
    Needs documentation:  0          |    Needs tests:  0
Patch needs improvement:  0          |  Easy pickings:  0
                  UI/UX:  0          |
-------------------------------------+-------------------------------------
 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.

--
Ticket URL: <https://code.djangoproject.com/ticket/29447>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

--
You received this message because you are subscribed to the Google Groups "Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/049.8e66fa8eadc8f20525bd2725913c535d%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #29447: RelatedManager.set() doesn't pass bulk keyword argument to clear()

Django
#29447: RelatedManager.set() doesn't pass bulk keyword argument to clear()
-------------------------------------+-------------------------------------
     Reporter:  Jeremy Lainé         |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:  Database layer       |                  Version:  2.0
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:
                                     |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Description changed by Jeremy Lainé:

Old 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.
New 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=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 `related_descriptors.py` code to fix
 #29440.

--

--
Ticket URL: <https://code.djangoproject.com/ticket/29447#comment:1>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

--
You received this message because you are subscribed to the Google Groups "Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/064.d3ca7950f9bc8c65050cf30ebd1cfee4%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #29447: RelatedManager.set() doesn't pass bulk keyword argument to clear()

Django
In reply to this post by Django
#29447: RelatedManager.set() doesn't pass bulk keyword argument to clear()
-------------------------------------+-------------------------------------
     Reporter:  Jeremy Lainé         |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:  Database layer       |                  Version:  2.0
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:
                                     |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by Alexander 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.

--
Ticket URL: <https://code.djangoproject.com/ticket/29447#comment:2>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

--
You received this message because you are subscribed to the Google Groups "Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/064.baa941a6fc65c9bb7d1bb5f5e6d8d00e%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #29447: RelatedManager.set() doesn't pass bulk keyword argument to clear()

Django
In reply to this post by Django
#29447: RelatedManager.set() doesn't pass bulk keyword argument to clear()
-------------------------------------+-------------------------------------
     Reporter:  Jeremy Lainé         |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:  Database layer       |                  Version:  2.0
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:  Accepted
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

 * stage:  Unreviewed => Accepted


--
Ticket URL: <https://code.djangoproject.com/ticket/29447#comment:3>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

--
You received this message because you are subscribed to the Google Groups "Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/064.27c97aaa82ffdf5770e15f804a437b6c%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #29447: RelatedManager.set() doesn't pass bulk keyword argument to clear()

Django
In reply to this post by Django
#29447: RelatedManager.set() doesn't pass bulk keyword argument to clear()
-------------------------------------+-------------------------------------
     Reporter:  Jeremy Lainé         |                    Owner:  Alexander
                                     |  Tatarinov
         Type:  Bug                  |                   Status:  assigned
    Component:  Database layer       |                  Version:  2.0
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:  Accepted
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Alexander Tatarinov):

 * owner:  nobody => Alexander Tatarinov
 * status:  new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/29447#comment:4>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

--
You received this message because you are subscribed to the Google Groups "Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/064.954a40c0d965f066d7f57b5c62900b15%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #29447: RelatedManager.set() doesn't pass bulk keyword argument to clear()

Django
In reply to this post by Django
#29447: RelatedManager.set() doesn't pass bulk keyword argument to clear()
-------------------------------------+-------------------------------------
     Reporter:  Jeremy Lainé         |                    Owner:  Alexander
                                     |  Tatarinov
         Type:  Bug                  |                   Status:  assigned
    Component:  Database layer       |                  Version:  2.0
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:  Accepted
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Alexander Tatarinov):

 * has_patch:  0 => 1


Comment:

 [https://github.com/django/django/pull/10089 PR]

--
Ticket URL: <https://code.djangoproject.com/ticket/29447#comment:5>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

--
You received this message because you are subscribed to the Google Groups "Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/064.96c554950aa9a01d474cbba1aa357d3d%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #29447: RelatedManager.set() doesn't pass bulk keyword argument to clear()

Django
In reply to this post by Django
#29447: RelatedManager.set() doesn't pass bulk keyword argument to clear()
-------------------------------------+-------------------------------------
     Reporter:  Jeremy Lainé         |                    Owner:  Alexandr
                                     |  Tatarinov
         Type:  Bug                  |                   Status:  closed
    Component:  Database layer       |                  Version:  2.0
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:  fixed
     Keywords:                       |             Triage Stage:  Accepted
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Tim Graham <timograham@…>):

 * status:  assigned => closed
 * resolution:   => fixed


Comment:

 In [changeset:"741061852851d6aff8e35f46b0e165685d3e79e0" 74106185]:
 {{{
 #!CommitTicketReference repository=""
 revision="741061852851d6aff8e35f46b0e165685d3e79e0"
 Fixed #29447 -- Made RelatedManager.set() pass bulk argument to clear().
 }}}

--
Ticket URL: <https://code.djangoproject.com/ticket/29447#comment:6>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

--
You received this message because you are subscribed to the Google Groups "Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/064.a014bf031969a1b6662113c4fe8e8118%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.