#24028: Related instance caching causes abstraction leaks from
Field.get_db_prep_save
-------------------------------------+-------------------------------------
Reporter: jdunck | Owner: nobody
Type: Bug | Status: new
Component: Database | Version: 1.5
layer (models, ORM) |
Severity: Normal | Keywords:
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
This is a regression from the introduction of
[[https://docs.djangoproject.com/en/dev/releases/1.5/#caching-of-related-
model-instances|related instance caching]] in 1.5.
{{{
class Foo(models.Model):
pass
class Bar(models.Model):
foo = models.OneToOneField(Foo)
value = models.DecimalField()
>>> foo = Foo.objects.create()
>>> bar = Bar.objects.create(foo=foo, value='1.0')
>>> foo.bar.value == Decimal('1.0')
}}}
The last line passes under 1.4, fails under 1.5+.
I think it would be reasonable to have a flag to Model.save which updates
field attributes to the result of Field.to_python(value), which would plug
this leak.
(I found this issue in production code under test, while upgrading from
1.4 to 1.5 on the way to 1.7.)
--
Ticket URL: <https://code.djangoproject.com/ticket/24028>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/049.34c9f2d0555263ada79b4fffd06e065e%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.