Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#24772 closed Bug (invalid)

Equality testing of deferred instances

Reported by: Josh Kupershmidt Owned by: nobody
Component: Database layer (models, ORM) Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

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 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?

Change History (2)

comment:1 by Simon Charette, 10 years ago

Resolution: invalid
Status: newclosed

Hi schmiddy,

This has been fixed in 6af05e7a0f0e4604d6a67899acaa99d73ec0dfaa which is included in 1.7.

comment:2 by Josh Kupershmidt, 10 years ago

Wonderful, thank you! I look forward to upgrading.

Note: See TracTickets for help on using tickets.
Back to Top