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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user