Skip to content

Commit 69e028f

Browse files
author
Mark Unsworth
committed
changed the flush command to not try and delete/remove records from capped collections
1 parent 5b4e11d commit 69e028f

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

django_mongodb_engine/base.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,20 @@ def sql_flush(self, style, tables, sequence_list, allow_cascade=False):
6060
drop all `tables`. No SQL in MongoDB, so just clear all tables
6161
here and return an empty list.
6262
"""
63+
64+
65+
6366
for table in tables:
6467
if table.startswith('system.'):
6568
# Do not try to drop system collections.
6669
continue
67-
self.connection.database[table].remove()
70+
71+
collection = self.connection.database[table]
72+
options = collection.options()
73+
74+
if not options.get('capped', False):
75+
collection.delete_many({})
76+
6877
return []
6978

7079
def validate_autopk_value(self, value):

0 commit comments

Comments
 (0)