Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions mssql/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,15 @@ def sqlserver_sha512(self, compiler, connection, **extra_context):
)


def sqlserver_iterator(queryset, chunk_size=2000):
steps = int(queryset.count() / chunk_size + 1)
step = 0
while step < steps:
for obj in queryset[chunk_size * step : (step + 1) * chunk_size]:
yield obj
step += 1


# `as_microsoft` called by django.db.models.sql.compiler based on connection.vendor
ATan2.as_microsoft = sqlserver_atan2
# Need copy of old In.split_parameter_list_as_sql for other backends to call
Expand Down Expand Up @@ -475,3 +484,4 @@ def sqlserver_sha512(self, compiler, connection, **extra_context):

OrderBy.as_microsoft = sqlserver_orderby
QuerySet.bulk_update = bulk_update_with_default
QuerySet.iterator = sqlserver_iterator