Fixed #17427 -- Removed dubious definition of connections equality.
This commit is contained in:
parent
d98cc41a84
commit
58de495c54
|
@ -73,17 +73,6 @@ class BaseDatabaseWrapper(object):
|
||||||
self.allow_thread_sharing = allow_thread_sharing
|
self.allow_thread_sharing = allow_thread_sharing
|
||||||
self._thread_ident = thread.get_ident()
|
self._thread_ident = thread.get_ident()
|
||||||
|
|
||||||
def __eq__(self, other):
|
|
||||||
if isinstance(other, BaseDatabaseWrapper):
|
|
||||||
return self.alias == other.alias
|
|
||||||
return NotImplemented
|
|
||||||
|
|
||||||
def __ne__(self, other):
|
|
||||||
return not self == other
|
|
||||||
|
|
||||||
def __hash__(self):
|
|
||||||
return hash(self.alias)
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def queries(self):
|
def queries(self):
|
||||||
if len(self.queries_log) == self.queries_log.maxlen:
|
if len(self.queries_log) == self.queries_log.maxlen:
|
||||||
|
|
|
@ -270,6 +270,9 @@ Miscellaneous
|
||||||
|
|
||||||
* ``connections.queries`` is now a read-only attribute.
|
* ``connections.queries`` is now a read-only attribute.
|
||||||
|
|
||||||
|
* Database connections are considered equal only if they're the same object.
|
||||||
|
They aren't hashable any more.
|
||||||
|
|
||||||
* ``URLField.to_python`` no longer adds a trailing slash to pathless URLs.
|
* ``URLField.to_python`` no longer adds a trailing slash to pathless URLs.
|
||||||
|
|
||||||
* ``django.contrib.gis`` dropped support for GEOS 3.1 and GDAL 1.6.
|
* ``django.contrib.gis`` dropped support for GEOS 3.1 and GDAL 1.6.
|
||||||
|
|
|
@ -1,36 +0,0 @@
|
||||||
from django.test import TestCase
|
|
||||||
from django.db.backends import BaseDatabaseWrapper
|
|
||||||
|
|
||||||
|
|
||||||
class DummyDatabaseWrapper(BaseDatabaseWrapper):
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class DummyObject(object):
|
|
||||||
alias = None
|
|
||||||
|
|
||||||
|
|
||||||
class DbBackendTests(TestCase):
|
|
||||||
def test_compare_db_wrapper_with_another_object(self):
|
|
||||||
wrapper = BaseDatabaseWrapper({})
|
|
||||||
self.assertFalse(wrapper == 'not-a-db-wrapper')
|
|
||||||
|
|
||||||
def test_compare_db_wrapper_with_another_object_with_alias(self):
|
|
||||||
wrapper = BaseDatabaseWrapper({})
|
|
||||||
obj = DummyObject()
|
|
||||||
obj.alias = wrapper.alias = 'foobar'
|
|
||||||
self.assertFalse(wrapper == obj)
|
|
||||||
|
|
||||||
def test_negate_compare_db_wrapper_with_another_object(self):
|
|
||||||
wrapper = BaseDatabaseWrapper({})
|
|
||||||
self.assertTrue(wrapper != 'not-a-db-wrapper')
|
|
||||||
|
|
||||||
def test_compare_db_wrappers(self):
|
|
||||||
wrapper1 = DummyDatabaseWrapper({})
|
|
||||||
wrapper2 = BaseDatabaseWrapper({})
|
|
||||||
|
|
||||||
wrapper1.alias = wrapper2.alias = 'foo'
|
|
||||||
self.assertTrue(wrapper1 == wrapper2)
|
|
||||||
|
|
||||||
wrapper1.alias = 'bar'
|
|
||||||
self.assertFalse(wrapper1 == wrapper2)
|
|
Loading…
Reference in New Issue