Skip to content

Commit 3513aac

Browse files
author
Mark Unsworth
committed
changed the flush method to check for capped collections and only remove all docs if the collection is not capped
1 parent cf040d7 commit 3513aac

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

django_mongodb_engine/base.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,13 @@ def sql_flush(self, style, tables, sequence_list, allow_cascade=False):
6464
if table.startswith('system.'):
6565
# Do not try to drop system collections.
6666
continue
67-
self.connection.database[table].remove()
67+
68+
collection = self.connection.database[table]
69+
options = collection.options()
70+
71+
if not options.get('capped', False):
72+
collection.remove({})
73+
6874
return []
6975

7076
def validate_autopk_value(self, value):

0 commit comments

Comments
 (0)