Refactor deferred model implementation
|Reported by:||Anssi Kääriäinen||Owned by:||nobody|
|Component:||Database layer (models, ORM)||Version:||master|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
There are a couple of places in the deferred model implementation which needed cleanup.
- in models/query_utils.py:
- the attribute loaded is dead code.
- the weak_ref to model isn't needed.
- improve the handling of inheritance primary key cases (if parent_ptr_id is already fetched, then assessing pk should not generate any database queries, as parent_ptr_id already contains the value).
- in models/base.py:
Model.__reduce__contained a dead variable, and stupid logic using that dead variable.
- a minor cleanup to tests/modeltests/field_subclassing/tests.py to spot errors earlier if they happen
The work is tracked in branch defer_inheritance_pk, I will create a pull request soon.