Skip to content

Commit f97aaa1

Browse files
author
Jannik Eilers
committed
943 MSSQL POC
1 parent 55850c2 commit f97aaa1

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

simple_history/management/commands/clean_duplicate_history.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,18 @@ def _process(self, to_process, date_back=None, dry_run=True):
9292
model_query = model_query.filter(
9393
pk__in=(m_qs.values_list(model._meta.pk.name).distinct())
9494
)
95+
def get_backend_name(model_class):
96+
from django.db import connections, router
97+
db_alias = router.db_for_read(model_class)
98+
return connections[db_alias].engine
99+
100+
backend_name = get_backend_name(model)
101+
if backend_name != 'mssql':
102+
_iterator = model_query.iterator()
103+
else:
104+
_iterator = model_query
95105

96-
for o in model_query.iterator():
106+
for o in _iterator:
97107
self._process_instance(o, model, stop_date=stop_date, dry_run=dry_run)
98108

99109
def _process_instance(self, instance, model, stop_date=None, dry_run=True):

0 commit comments

Comments
 (0)