Skip to content

Commit

Permalink
943 MSSQL POC
Browse files Browse the repository at this point in the history
  • Loading branch information
Jannik Eilers committed Feb 10, 2025
1 parent 55850c2 commit 7c4cf10
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion simple_history/management/commands/clean_duplicate_history.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,18 @@ def _process(self, to_process, date_back=None, dry_run=True):
pk__in=(m_qs.values_list(model._meta.pk.name).distinct())
)

for o in model_query.iterator():
def get_backend_name(model_class):
from django.db import connections, router
db_alias = router.db_for_read(model_class)
return connections[db_alias].vendor

backend_name = get_backend_name(model)
if backend_name != 'microsoft':
_iterator = model_query.iterator()
else:
_iterator = model_query

for o in _iterator:
self._process_instance(o, model, stop_date=stop_date, dry_run=dry_run)

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

0 comments on commit 7c4cf10

Please sign in to comment.