Skip to content

Commit e4fe62a

Browse files
committed
remove broken write concern implementation
This code came from django-mongodb-engine and doesn't work with the latest pymongo APIs.
1 parent bdd2a40 commit e4fe62a

File tree

3 files changed

+5
-18
lines changed

3 files changed

+5
-18
lines changed

django_mongodb/base.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -148,19 +148,10 @@ def __getattr__(self, attr):
148148

149149
def _connect(self):
150150
settings_dict = self.settings_dict
151-
152-
options = settings_dict["OPTIONS"]
153-
# TODO: review and document OPERATIONS: https://github.com/mongodb-labs/django-mongodb/issues/6
154-
self.operation_flags = options.pop("OPERATIONS", {})
155-
if not any(k in ["save", "delete", "update"] for k in self.operation_flags):
156-
# Flags apply to all operations.
157-
flags = self.operation_flags
158-
self.operation_flags = {"save": flags, "delete": flags, "update": flags}
159-
160151
self.connection = MongoClient(
161152
host=settings_dict["HOST"] or None,
162153
port=int(settings_dict["PORT"] or 27017),
163-
**options,
154+
**settings_dict["OPTIONS"],
164155
)
165156
db_name = settings_dict["NAME"]
166157
if db_name:

django_mongodb/compiler.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -517,8 +517,7 @@ def execute_sql(self, returning_fields=None):
517517
def insert(self, docs, returning_fields=None):
518518
"""Store a list of documents using field columns as element names."""
519519
collection = self.get_collection()
520-
options = self.connection.operation_flags.get("save", {})
521-
inserted_ids = collection.insert_many(docs, **options).inserted_ids
520+
inserted_ids = collection.insert_many(docs).inserted_ids
522521
return inserted_ids if returning_fields else []
523522

524523

@@ -582,15 +581,13 @@ def update(self, values):
582581
return self.execute_update(spec)
583582

584583
@wrap_database_errors
585-
def execute_update(self, update_spec, **kwargs):
584+
def execute_update(self, update_spec):
586585
collection = self.get_collection()
587586
try:
588587
criteria = self.build_query().mongo_query
589588
except EmptyResultSet:
590589
return 0
591-
options = self.connection.operation_flags.get("update", {})
592-
options = dict(options, **kwargs)
593-
return collection.update_many(criteria, update_spec, **options).matched_count
590+
return collection.update_many(criteria, update_spec).matched_count
594591

595592
def check_query(self):
596593
super().check_query()

django_mongodb/query.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,7 @@ def __repr__(self):
5858
@wrap_database_errors
5959
def delete(self):
6060
"""Execute a delete query."""
61-
options = self.connection.operation_flags.get("delete", {})
62-
return self.collection.delete_many(self.mongo_query, **options).deleted_count
61+
return self.collection.delete_many(self.mongo_query).deleted_count
6362

6463
@wrap_database_errors
6564
def get_cursor(self):

0 commit comments

Comments
 (0)