#28166 closed Bug (fixed)
Model _state.db for an inherited object is not correctly populated to parent object
Reported by: | wckao | Owned by: | nobody |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | 1.11 |
Severity: | Release blocker | Keywords: | |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
For the following models:
class ModelA(models.Model): name = models.CharField(max_length=10) class ModelB(ModelA): is_active = models.BooleanField()
On shell:
b = ModelB.objects.create(name="test", is_active=True) b.id = None b.pk = None b.save() print(b._state.db, b.modela_ptr._state.db)
On 1.10, it shows "default default",
but after upgrading from 1.10 to 1.11, it shows "default None"
Change History (6)
comment:1 by , 8 years ago
Summary: | Model _state.db for an inherited object is not correctly populated → Model _state.db for an inherited object is not correctly populated to parent object |
---|
comment:2 by , 8 years ago
Component: | Uncategorized → Database layer (models, ORM) |
---|---|
Severity: | Normal → Release blocker |
Triage Stage: | Unreviewed → Accepted |
Type: | Uncategorized → Bug |
comment:3 by , 8 years ago
It should only be a matter of storing the result of rel_model
in a temporary variable to assign _state.db = instance._state.db
to it before returning in ForwardOneToOneDescriptor. get_object().
Note:
See TracTickets
for help on using tickets.
Bisected to 38575b007a722d6af510ea46d46393a4cda9ca29.