when inheriting models, accessing related subclass instances can produce spurious relations depending on order
|Reported by:||admackin||Owned by:||socrates|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
If you are using the new multi-table inheritance feature, and have two or more subclasses (eg SubClassA and SubClassB) which inherits from a baseclass, and retrieve a base class instance baseinstance from the DB, the expected behaviour if baseinstance only has a corresponding SubClassA instance should be to throw a DoesNotExist exception when accessing baseinstance.subclassb. However, if you have already accessed baseinstance.subclassa, baseinstance.subclassb will point to the corresponding SubClassA instance instead of raising the exception.
The attached models.py includes a test case that documents this.
Change History (12)
Changed 8 years ago by admackin
comment:1 Changed 8 years ago by socrates
- Needs documentation unset
- Needs tests unset
- Owner changed from nobody to socrates
- Patch needs improvement unset