#23931: db_manager() method doesn't increment creation_counter
-------------------------------------+-------------------------------------
Reporter: rhettg | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: 1.7
(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
-------------------------------------+-------------------------------------
Comment (by loic):
I'm sitting on the fence here.
`db_manager()` was designed to generate short-lived managers, not to be
assigned as class managers. That said, other short-lived managers (and
short-lived fields in custom lookups/expressions for that matter) increase
the creation counters (e.g. `Category().article_set`) so `db_manager()`
probably should too, if only for consistency.
However supporting non-empty `db` or `hints` attributes for long-lived
managers is something that would require a fair amount of investigation
and some hard design decisions:
- Are these supposed to be default values to be used when nothing else is
provided at query time? In that case what about `hints`, should they be
merged? Current implementation of `RelatedManager.get_queryset()`
completely overrides `hints`.
- Are these supposed to be definitive values? Current implementation of
`RelatedManager.create|get_or_create|update_or_create()` asks the router
directly for `db` and doesn't account that one may be set already on the
manager.
If we recognize that long-lived managers can have a `db` or `hints` state
(as it would be the case if we made them `__init__()` arguments) then we
must define the behavior. Right now setting these may work for some cases,
but the behavior is largely undefined as far as Django is concerned.
--
Ticket URL: <https://code.djangoproject.com/ticket/23931#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 [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/064.bdb0e45b16cb7f5300e30a763095069d%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.