diff options
| author | Anssi Kääriäinen <akaariai@gmail.com> | 2012-11-24 00:44:48 +0200 |
|---|---|---|
| committer | Anssi Kääriäinen <akaariai@gmail.com> | 2012-11-24 01:20:22 +0200 |
| commit | 421e599ad34b93e9537bf4deeca343f5b2e69f06 (patch) | |
| tree | c9e817f3ed17e396864b652e41676d85fe86a92f /django/db/backends/sqlite3 | |
| parent | 625dc3f0722d80eaffacc39171ea7337ab089ae4 (diff) | |
[1.5.x] Fixed #19351 -- SQLite bulk_insert of more than 500 single-field objs
Backpatch of 0a0a0d66b316598f7c296e8bf75749a14ce3ac49
Diffstat (limited to 'django/db/backends/sqlite3')
| -rw-r--r-- | django/db/backends/sqlite3/base.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/django/db/backends/sqlite3/base.py b/django/db/backends/sqlite3/base.py index 7f0c51dd50..6b6c6b67d9 100644 --- a/django/db/backends/sqlite3/base.py +++ b/django/db/backends/sqlite3/base.py @@ -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 |
