Changes between Initial Version and Version 1 of Ticket #17427, comment 5


Ignore:
Timestamp:
Dec 17, 2011, 7:40:32 AM (13 years ago)
Author:
Anssi Kääriäinen

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #17427, comment 5

    initial v1  
    33The 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.
    44
    5 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.
     5Previously if you transferred the DBWrapper in connections[some_alias] from thread 1 to thread 2, then the transferred DBWrapper and connections[some_alias] 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. Now the transferred DBWrapper would have a different connection.
    66
    7 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.
     7I 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.
Back to Top