first adaptations after comments and find-outs
This commit is contained in:
parent
46817caa68
commit
ccbd128fa2
@ -8,8 +8,9 @@ __all__ = ['ConnectionError', 'connect', 'register_connection',
|
||||
|
||||
DEFAULT_CONNECTION_NAME = 'default'
|
||||
if pymongo.version_tuple[0] >= 3:
|
||||
READ_PREFERENCE = ReadPreference.SECONDARY_PREFERRED
|
||||
READ_PREFERENCE = ReadPreference.PRIMARY
|
||||
else:
|
||||
from pymongo import MongoReplicaSetClient
|
||||
READ_PREFERENCE = False
|
||||
|
||||
|
||||
@ -126,6 +127,8 @@ def get_connection(alias=DEFAULT_CONNECTION_NAME, reconnect=False):
|
||||
if conn_settings == connection_settings and _connections.get(db_alias, None):
|
||||
connection = _connections[db_alias]
|
||||
break
|
||||
if pymongo.version_tuple[0] < 3:
|
||||
connection_class = MongoReplicaSetClient
|
||||
|
||||
_connections[alias] = connection if connection else connection_class(**conn_settings)
|
||||
except Exception, e:
|
||||
|
@ -295,10 +295,10 @@ class Document(BaseDocument):
|
||||
|
||||
# I think the self._created flag is not necessarily required in PyMongo3
|
||||
# but may cause test test_collection_name_and_primary to fail
|
||||
if pymongo.version_tuple[0] < 3:
|
||||
# if pymongo.version_tuple[0] < 3:
|
||||
created = ('_id' not in doc or self._created or force_insert)
|
||||
else:
|
||||
created = ('_id' not in doc or force_insert)
|
||||
# else:
|
||||
# created = ('_id' not in doc or force_insert)
|
||||
|
||||
signals.pre_save_post_validation.send(self.__class__, document=self,
|
||||
created=created)
|
||||
|
@ -424,8 +424,6 @@ class BaseQuerySet(object):
|
||||
if call_document_delete:
|
||||
cnt = 0
|
||||
for doc in queryset:
|
||||
# How the fuck did this worked before ???
|
||||
# doc.delete(write_concern=write_concern)
|
||||
doc.delete(**write_concern)
|
||||
cnt += 1
|
||||
return cnt
|
||||
|
@ -509,9 +509,9 @@ class IndexesTest(unittest.TestCase):
|
||||
|
||||
self.assertEqual(BlogPost.objects.count(), 10)
|
||||
self.assertEqual(BlogPost.objects.hint().count(), 10)
|
||||
# here we seem to have find a bug in PyMongo 3.
|
||||
# The cursor first makes a SON out of the list of tuples
|
||||
# Then later reuses it and wonders why is it not a list of tuples
|
||||
|
||||
# PyMongo 3.0 bug
|
||||
if pymongo.version != '3.0':
|
||||
self.assertEqual(BlogPost.objects.hint([('tags', 1)]).count(), 10)
|
||||
|
||||
self.assertEqual(BlogPost.objects.hint([('ZZ', 1)]).count(), 10)
|
||||
|
Loading…
x
Reference in New Issue
Block a user