#29310: ManyRelatedManager.add() does not accept `bulk` kwarg as described in
documentation
-------------------------------------+-------------------------------------
Reporter: Brenton | Owner: nobody
Partridge |
Type: Bug | Status: new
Component: Database | Version: master
layer (models, ORM) |
Severity: Normal | Keywords: documentation, orm
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
https://docs.djangoproject.com/en/2.0/ref/models/relations/#django.db.models.fields.related.RelatedManager.add
suggests that `RelatedManager.add(*objs, bulk=True)` accepts the `bulk`
kwarg regardless of the type of relationship. However, for many-to-many
relationships,
https://github.com/django/django/blob/2919a08c20d5ae48e381d6bd251d3b0d400d47d9/django/db/models/fields/related_descriptors.py#L909
does not accept any kwargs. (Master branch as of the submission of this
ticket.)
This leads to errors like `add() got an unexpected keyword argument
‘bulk’`.
This could be fixed in documentation, since for many-to-many the inserts
are going to be bulk regardless. But then RelatedManager wouldn't have a
consistent interface across all types of relations. Alternately, we could
just add the kwarg to the code and ignore it, and document more clearly
that "all many-to-many adds are inserted in bulk, regardless of the choice
of bulk kwarg." But we shouldn't just error out on a developer who
attempts to follow the documentation.
Any thoughts?
--
Ticket URL: <https://code.djangoproject.com/ticket/29310>
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/053.89dee99068390a9b8f0393d46a95fe68%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.