diff options
| author | guro-Ishiguro <guro120411@gmail.com> | 2025-12-23 00:30:05 +0900 |
|---|---|---|
| committer | Jacob Walls <jacobtylerwalls@gmail.com> | 2025-12-22 20:33:39 -0500 |
| commit | 847b2badccbd87fc3e657725eb316b092265912d (patch) | |
| tree | 3579dc4cfe99b60f06d9a47f36c0826dd13087a6 | |
| parent | f31445f2e7e1091ab4de81b9c994052fc6842e22 (diff) | |
[6.0.x] Fixed #36818 -- Ensured SQLite connection before accessing max_query_params.
Regression in 358fd21c47cdf7bda520ce73c5cfd82bba57827b.
Backport of 84bae9c22a8ae7663c56cce5e0c611ea7c17fce1 from main.
| -rw-r--r-- | django/db/backends/sqlite3/features.py | 1 | ||||
| -rw-r--r-- | docs/releases/6.0.1.txt | 4 | ||||
| -rw-r--r-- | tests/backends/sqlite/test_features.py | 11 |
3 files changed, 16 insertions, 0 deletions
diff --git a/django/db/backends/sqlite3/features.py b/django/db/backends/sqlite3/features.py index 143ee1e98b..a6c8ff643d 100644 --- a/django/db/backends/sqlite3/features.py +++ b/django/db/backends/sqlite3/features.py @@ -149,6 +149,7 @@ class DatabaseFeatures(BaseDatabaseFeatures): 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). """ + self.connection.ensure_connection() return self.connection.connection.getlimit(sqlite3.SQLITE_LIMIT_VARIABLE_NUMBER) @cached_property diff --git a/docs/releases/6.0.1.txt b/docs/releases/6.0.1.txt index 36e533a888..1580512409 100644 --- a/docs/releases/6.0.1.txt +++ b/docs/releases/6.0.1.txt @@ -20,3 +20,7 @@ Bugfixes * Fixed a bug where management command colorized help (introduced in Python 3.14) ignored the :option:`--no-color` option and the :envvar:`DJANGO_COLORS` setting (:ticket:`36376`). + +* Fixed a regression in Django 6.0 that caused + :meth:`~django.db.models.query.QuerySet.bulk_create` to crash + when introspecting the connection on SQLite (:ticket:`36818`). diff --git a/tests/backends/sqlite/test_features.py b/tests/backends/sqlite/test_features.py index 95e060fbcc..45c3ec9f2c 100644 --- a/tests/backends/sqlite/test_features.py +++ b/tests/backends/sqlite/test_features.py @@ -1,3 +1,4 @@ +import copy import sqlite3 from unittest import mock, skipUnless @@ -29,3 +30,13 @@ class FeaturesTests(TestCase): finally: connection.connection.setlimit(limit_name, current_limit) self.assertEqual(connection.features.max_query_params, current_limit) + + def test_max_query_params_without_established_connection(self): + new_connection = connection.copy() + new_connection.settings_dict = copy.deepcopy(connection.settings_dict) + self.assertIsNone(new_connection.connection) + try: + result = new_connection.features.max_query_params + self.assertIsInstance(result, int) + finally: + new_connection._close() |
