#24772: Equality testing of deferred instances
----------------------------------------------+--------------------
Reporter: schmiddy | Owner: nobody
Type: Bug | Status: new
Component: Database layer (models, ORM) | Version: master
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
----------------------------------------------+--------------------
I find this behavior quite surprising and unintuitive:
{{{
a = MyModel.objects.get(id=1)
b = MyModel.objects.defer('hugefield').get(id=1)
a == b # False
}}}
Tested on 1.6.3, though AFAICT the behavior should be the same in git
master. I notice I'm [https://stackoverflow.com/questions/3617886/django-
queryset-defer-problem-bug-or-feature not the only one] who has gotten
tripped up by this behavior. I haven't seen any comments suggesting this
behavior is intentional, so I'm guessing it's an accident of how
Model.!__eq!__ is implemented and how deferred instances get a new class,
rather than a conscious choice.
Is there support for changing this behavior so that a would equal b in
this example?
--
Ticket URL: <https://code.djangoproject.com/ticket/24772>
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/051.a236f971e386519c0dc29c7ebfab9524%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.