#28282: Index.set_name_with_model() not called on models without a base meta
class
-------------------------------------+-------------------------------------
Reporter: Jon | Owner: nobody
Dufresne |
Type: Bug | Status: new
Component: Database | Version: 1.11
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 |
-------------------------------------+-------------------------------------
From
https://github.com/django/django/blob/23825b2494a1edb1e02d57dbdc7eca0614cefcc8/django/db/models/base.py#L296-L303
{{{
if base_meta and base_meta.abstract and not abstract:
new_class._meta.indexes = [copy.deepcopy(idx) for idx in
new_class._meta.indexes]
# Set the name of _meta.indexes. This can't be done in
# Options.contribute_to_class() because fields haven't been
added
# to the model at that point.
for index in new_class._meta.indexes:
if not index.name:
index.set_name_with_model(new_class)
}}}
I believe the condition should be changed to `if (not base_meta or
base_meta.abstract) and not abstract:`. Or maybe simply `if not abstract`?
As of right now simple classes inheriting from `models.Model` have
`base_meta` as `None` and so the indexes aren't named.
--
Ticket URL: <https://code.djangoproject.com/ticket/28282>
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/052.0bd1ff9776fbc642db1d77ac9251ee20%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.