diff --git a/src/sentry/utils/query.py b/src/sentry/utils/query.py index 0af01b9102d883..bcf8b3b9f09bbd 100644 --- a/src/sentry/utils/query.py +++ b/src/sentry/utils/query.py @@ -261,7 +261,7 @@ def bulk_delete_objects( if column.endswith("__in"): column, _ = column.split("__") query.append(f"{quote_name(column)} = ANY(%s)") - params.append(value) + params.append(list(value)) else: query.append(f"{quote_name(column)} = %s") params.append(value) diff --git a/tests/sentry/utils/test_query.py b/tests/sentry/utils/test_query.py index 68a4052f78f6b2..fd600de9c69ba6 100644 --- a/tests/sentry/utils/test_query.py +++ b/tests/sentry/utils/test_query.py @@ -79,6 +79,26 @@ def test_basic(self): assert result, "Could be more work to do" assert len(UserReport.objects.all()) == 0 + def test_basic_tuple(self): + total = 10 + records = [] + for i in range(total): + records.append(self.create_userreport(project=self.project, event_id=str(i) * 32)) + + result = bulk_delete_objects(UserReport, id__in=tuple([r.id for r in records])) + assert result, "Could be more work to do" + assert len(UserReport.objects.all()) == 0 + + def test_basic_set(self): + total = 10 + records = [] + for i in range(total): + records.append(self.create_userreport(project=self.project, event_id=str(i) * 32)) + + result = bulk_delete_objects(UserReport, id__in={r.id for r in records}) + assert result, "Could be more work to do" + assert len(UserReport.objects.all()) == 0 + def test_limiting(self): total = 10 records = []