Index.set_name_with_model() not called on models without a base meta class
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.
Change History
(4)
Severity: |
Normal → Release blocker
|
Triage Stage: |
Unreviewed → Ready for checkin
|
Resolution: |
→ fixed
|
Status: |
new → closed
|
PR