#25296: Failed Manager.create pollutes related models cache in 1.8.4
-------------------------------------+-------------------------------------
Reporter: rubendura | Owner: nobody
Type: Uncategorized | Status: new
Component: Database layer | Version: 1.8
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by rubendura):
Basically I still believe the behaviour should be considered buggy.
When I call get_or_create() (or create(), I believe it doesn't make a
difference) and exception is thrown, and as such I can't get a reference
to the object being created (technically it hasn't been created, an
exception was thrown during the process so no changes should've been
made). However, even I couldn't get a hold of that object myself, some
other objects I have roaming around my system got references to it, to
that never-created-object that threw an exception.
Say I had some code like this:
{{{
try:
token = Token.objects.create(user=user)
except ValueError:
# Can't use token variable here (no token should be created)
# user.token should raise an exception, yet it contains an unsaved
token
pass
else:
# All good, use token variable as usual
pass
}}}
If ValueError is raised, the token variable is unusable on the except
block, yet I can see some debris floating around in other objects, thus
polluting them. I can basically access a model that should've never been
created (either saved on the db or not).
--
Ticket URL: <https://code.djangoproject.com/ticket/25296#comment:4>
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/067.a8e48bd5bb4fbeeb13e8011b58252921%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.