1
0
mirror of https://github.com/django/django.git synced 2025-10-23 21:59:11 +00:00

[1.5.x] Fixed #19351 -- SQLite bulk_insert of more than 500 single-field objs

Backpatch of 0a0a0d66b3
This commit is contained in:
Anssi Kääriäinen
2012-11-24 00:44:48 +02:00
parent 625dc3f072
commit 421e599ad3
2 changed files with 13 additions and 1 deletions

View File

@@ -120,8 +120,12 @@ class DatabaseOperations(BaseDatabaseOperations):
"""
SQLite has a compile-time default (SQLITE_LIMIT_VARIABLE_NUMBER) of
999 variables per query.
If there is just single field to insert, then we can hit another
limit, SQLITE_MAX_COMPOUND_SELECT which defaults to 500.
"""
return (999 // len(fields)) if len(fields) > 0 else len(objs)
limit = 999 if len(fields) > 1 else 500
return (limit // len(fields)) if len(fields) > 0 else len(objs)
def date_extract_sql(self, lookup_type, field_name):
# sqlite doesn't support extract, so we fake it with the user-defined