#17427: DatabaseWrapper no longer hashable-> failure in test_connections_thread_local -------------------------------------+------------------------------------- Reporter: vsajip | Owner: nobody Type: Uncategorized | Status: new Component: Database layer | Version: SVN (models, ORM) | Resolution: Severity: Normal | Triage Stage: Keywords: | Unreviewed Has patch: 0 | Needs documentation: 0 Needs tests: 0 | Patch needs improvement: 0 Easy pickings: 0 | UI/UX: 0 -------------------------------------+-------------------------------------
Comment (by akaariai): I did a little investigation, and to me it seems the correct fix is to not define `__eq__` or `__hash__` at all, that is, they are inherited from object, and thus only same instance is equal. The current equality test using alias isn't a sane test anymore. Previously you had to try extra-hard to get two different instances in one thread to point to the same alias. Now this is much easier to do. So, if you have two DBWrappers pointing to the same alias but using different connections, I don't see a reason why they should be equal. Other possibility would be to base the the equality on the underlying connection equality, that is self.connection == other.connection. Previously if you transferred the DBWrapper in connections[some_alias] from thread 1 to thread 2, the transferred DBWrapper would have pointed to the same connection in thread 2 (because the DBWrapper instance was threading.local). So, if you tested self.alias == other.alias you would be testing that the connection is the same, too. This is no longer true. I hope the above explanation makes some sense. Making this change will require some minor changes to Django code. But the bigger deal is if this breaks user code in backwards incompatible way. User code relying on .alias equality is no longer correct, and instance equality will give the same result as long as you don't transfer connections between threads or anything like that. So, no problems should be caused to users by this. -- Ticket URL: <https://code.djangoproject.com/ticket/17427#comment:5> 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 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.