Skip to content

Commit 7c4cf10

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

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

simple_history/management/commands/clean_duplicate_history.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,18 @@ def _process(self, to_process, date_back=None, dry_run=True):
9393
pk__in=(m_qs.values_list(model._meta.pk.name).distinct())
9494
)
9595

96-
for o in model_query.iterator():
96+
def get_backend_name(model_class):
97+
from django.db import connections, router
98+
db_alias = router.db_for_read(model_class)
99+
return connections[db_alias].vendor
100+
101+
backend_name = get_backend_name(model)
102+
if backend_name != 'microsoft':
103+
_iterator = model_query.iterator()
104+
else:
105+
_iterator = model_query
106+
107+
for o in _iterator:
97108
self._process_instance(o, model, stop_date=stop_date, dry_run=dry_run)
98109

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

0 commit comments

Comments
 (0)