Ensure add_stator_indexes only run for direct descendants of StatorModel#696
Ensure add_stator_indexes only run for direct descendants of StatorModel#696lullis wants to merge 1 commit intojointakahe:mainfrom
Conversation
|
Does this have a bug associated with it? What's the behavior you're trying to prevent? |
|
The issue is that these indices only make sense on models that derive directly from StatorModel. If you create any other model that itself is already derived from StatorModel (e.g, Identity) then the system will fail the check due to issues with the indices that are not related to the table you are creating. |
c8dcdc9 to
021d16b
Compare
|
Ah, ok, yeah, if you have a concrete model inheriting from a concrete model (Multi Table Inheritance), this code will fail because the indexed columns only exist on the parent table. This largely looks good, but I'm going to double check some things. |
| StatorModel, otherwise we will see system check errors. | ||
| """ | ||
| if issubclass(sender, StatorModel): | ||
| if sender.__base__ is StatorModel: |
There was a problem hiding this comment.
I'm not completely thrilled with this--__base__ is semi-documented, and points to the first parent class.
But I'm not sure what multiple inheritance would do in the context of Django models.
No description provided.