#11892: Model __eq__ is not symmetric. -----------------------------------------------+---------------------------- Reporter: pmcnerth...@clearpointmetrics.com | Owner: nobody Status: new | Milestone: Component: Database layer (models, ORM) | Version: 1.1 Keywords: | Stage: Unreviewed Has_patch: 0 | -----------------------------------------------+---------------------------- The Model test for equal implemented in eq is not symmetric. A non- deferred instance compares equal to a deferred instance, but a deferred instance compares unequal to a non-deferred instance. This is due to the following implementation of eq:
{{{ def __eq__(self, other): return isinstance(other, self.__class__ and self._get_pk_val() == other._get_pk_val() }}} This needs to be changed to: {{{ def __eq__(self, other): return (isinstance(other, self.__class__) or isinstance(self, other.__class__)) and self._get_pk_val() == other._get_pk_val() }}} Which allows for complete symmetric of comparisons. -- Ticket URL: <http://code.djangoproject.com/ticket/11892> Django <http://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 post to this group, send email to django-updates@googlegroups.com To unsubscribe from this group, send email to django-updates+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-updates?hl=en -~----------~----~----~----~------~----~------~--~---