mirror of
https://github.com/django/django.git
synced 2025-10-27 07:36:08 +00:00
Fixed #36143 -- Made max_query_params respect SQLITE_LIMIT_VARIABLE_NUMBER.
Co-authored-by: Xavier Frankline <xf.xavierfrank@gmail.com>
This commit is contained in:
committed by
Sarah Boyce
parent
38660a612c
commit
358fd21c47
@@ -1,4 +1,5 @@
|
||||
import operator
|
||||
import sqlite3
|
||||
|
||||
from django.db import transaction
|
||||
from django.db.backends.base.features import BaseDatabaseFeatures
|
||||
@@ -13,7 +14,6 @@ class DatabaseFeatures(BaseDatabaseFeatures):
|
||||
test_db_allows_multiple_connections = False
|
||||
supports_unspecified_pk = True
|
||||
supports_timezones = False
|
||||
max_query_params = 999
|
||||
supports_transactions = True
|
||||
atomic_transactions = False
|
||||
can_rollback_ddl = True
|
||||
@@ -140,6 +140,16 @@ class DatabaseFeatures(BaseDatabaseFeatures):
|
||||
"SmallAutoField": "AutoField",
|
||||
}
|
||||
|
||||
@property
|
||||
def max_query_params(self):
|
||||
"""
|
||||
SQLite has a variable limit per query. The limit can be changed using
|
||||
the SQLITE_MAX_VARIABLE_NUMBER compile-time option (which defaults to
|
||||
999 in versions < 3.32.0 or 32766 in newer versions) or lowered per
|
||||
connection at run-time with setlimit(SQLITE_LIMIT_VARIABLE_NUMBER, N).
|
||||
"""
|
||||
return self.connection.connection.getlimit(sqlite3.SQLITE_LIMIT_VARIABLE_NUMBER)
|
||||
|
||||
@cached_property
|
||||
def supports_json_field(self):
|
||||
with self.connection.cursor() as cursor:
|
||||
|
||||
@@ -30,8 +30,8 @@ class DatabaseOperations(BaseDatabaseOperations):
|
||||
|
||||
def bulk_batch_size(self, fields, objs):
|
||||
"""
|
||||
SQLite has a compile-time default (SQLITE_LIMIT_VARIABLE_NUMBER) of
|
||||
999 variables per query.
|
||||
SQLite has a variable limit defined by SQLITE_LIMIT_VARIABLE_NUMBER
|
||||
(reflected in max_query_params).
|
||||
|
||||
If there's only a single field to insert, the limit is 500
|
||||
(SQLITE_MAX_COMPOUND_SELECT).
|
||||
|
||||
Reference in New Issue
Block a user