1
0
mirror of https://github.com/django/django.git synced 2025-11-07 07:15:35 +00:00

Fixed #36671 -- Dropped support for SQLite < 3.37.

This commit is contained in:
Mariusz Felisiak
2025-10-18 21:04:11 +02:00
committed by GitHub
parent 0c487aa3a7
commit d506e4a528
8 changed files with 16 additions and 27 deletions

View File

@@ -10,7 +10,7 @@ from .base import Database
class DatabaseFeatures(BaseDatabaseFeatures):
minimum_database_version = (3, 31)
minimum_database_version = (3, 37)
test_db_allows_multiple_connections = False
supports_unspecified_pk = True
supports_timezones = False
@@ -26,8 +26,6 @@ class DatabaseFeatures(BaseDatabaseFeatures):
time_cast_precision = 3
can_release_savepoints = True
has_case_insensitive_like = True
# Is "ALTER TABLE ... DROP COLUMN" supported?
can_alter_table_drop_column = Database.sqlite_version_info >= (3, 35, 5)
supports_parentheses_in_compound = False
can_defer_constraint_checks = True
supports_over_clause = True
@@ -57,6 +55,9 @@ class DatabaseFeatures(BaseDatabaseFeatures):
insert_test_table_with_defaults = 'INSERT INTO {} ("null") VALUES (1)'
supports_default_keyword_in_insert = False
supports_unlimited_charfield = True
can_return_columns_from_insert = True
can_return_rows_from_bulk_insert = True
can_return_rows_from_update = True
@cached_property
def django_test_skips(self):
@@ -146,8 +147,8 @@ class DatabaseFeatures(BaseDatabaseFeatures):
"""
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).
32766) or lowered per connection at run-time with
setlimit(SQLITE_LIMIT_VARIABLE_NUMBER, N).
"""
return self.connection.connection.getlimit(sqlite3.SQLITE_LIMIT_VARIABLE_NUMBER)
@@ -163,15 +164,3 @@ class DatabaseFeatures(BaseDatabaseFeatures):
can_introspect_json_field = property(operator.attrgetter("supports_json_field"))
has_json_object_function = property(operator.attrgetter("supports_json_field"))
@cached_property
def can_return_columns_from_insert(self):
return Database.sqlite_version_info >= (3, 35)
can_return_rows_from_bulk_insert = property(
operator.attrgetter("can_return_columns_from_insert")
)
can_return_rows_from_update = property(
operator.attrgetter("can_return_columns_from_insert")
)

View File

@@ -342,8 +342,7 @@ class DatabaseIntrospection(BaseDatabaseIntrospection):
"PRAGMA index_list(%s)" % self.connection.ops.quote_name(table_name)
)
for row in cursor.fetchall():
# SQLite 3.8.9+ has 5 columns, however older versions only give 3
# columns. Discard last 2 columns if there.
# Discard last 2 columns.
number, index, unique = row[:3]
cursor.execute(
"SELECT sql FROM sqlite_master WHERE type='index' AND name=%s",

View File

@@ -339,10 +339,9 @@ class DatabaseSchemaEditor(BaseDatabaseSchemaEditor):
self.delete_model(field.remote_field.through)
# For explicit "through" M2M fields, do nothing
elif (
self.connection.features.can_alter_table_drop_column
# Primary keys, unique fields, indexed fields, and foreign keys are
# not supported in ALTER TABLE DROP COLUMN.
and not field.primary_key
not field.primary_key
and not field.unique
and not field.db_index
and not (field.remote_field and field.db_constraint)

View File

@@ -60,7 +60,7 @@ Database Library Requirements Supported Versions Notes
PostgreSQL GEOS, GDAL, PROJ, PostGIS 15+ Requires PostGIS.
MySQL GEOS, GDAL 8.0.11+ :ref:`Limited functionality <mysql-spatial-limitations>`.
Oracle GEOS, GDAL 19+ XE not supported.
SQLite GEOS, GDAL, PROJ, SpatiaLite 3.31.0+ Requires SpatiaLite 4.3+
SQLite GEOS, GDAL, PROJ, SpatiaLite 3.37.0+ Requires SpatiaLite 4.3+
================== ============================== ================== =========================================
See also `this comparison matrix`__ on the OSGeo Wiki for

View File

@@ -814,7 +814,7 @@ appropriate typecasting.
SQLite notes
============
Django supports SQLite 3.31.0 and later.
Django supports SQLite 3.37.0 and later.
SQLite_ provides an excellent development alternative for applications that
are predominantly read-only or require a smaller installation footprint. As

View File

@@ -2439,8 +2439,8 @@ This has a number of caveats though:
* If the model's primary key is an :class:`~django.db.models.AutoField` or has
a :attr:`~django.db.models.Field.db_default` value, and ``ignore_conflicts``
is ``False``, the primary key attribute can only be retrieved on certain
databases (currently PostgreSQL, MariaDB, and SQLite 3.35+). On other
databases, it will not be set.
databases (currently PostgreSQL, MariaDB, and SQLite). On other databases, it
will not be set.
* It does not work with many-to-many relationships.
* It casts ``objs`` to a list, which fully evaluates ``objs`` if it's a
generator. The cast allows inspecting all objects so that any objects with a

View File

@@ -325,6 +325,8 @@ Miscellaneous
* :class:`~django.contrib.contenttypes.fields.GenericForeignKey` now uses a
separate descriptor class: the private ``GenericForeignKeyDescriptor``.
* The minimum supported version of SQLite is increased from 3.31.0 to 3.37.0.
.. _deprecated-features-6.1:
Features deprecated in 6.1

View File

@@ -109,9 +109,9 @@ class Tests(TestCase):
connections["default"].close()
self.assertTrue(os.path.isfile(os.path.join(tmp, "test.db")))
@mock.patch.object(connection, "get_database_version", return_value=(3, 30))
@mock.patch.object(connection, "get_database_version", return_value=(3, 36))
def test_check_database_version_supported(self, mocked_get_database_version):
msg = "SQLite 3.31 or later is required (found 3.30)."
msg = "SQLite 3.37 or later is required (found 3.36)."
with self.assertRaisesMessage(NotSupportedError, msg):
connection.check_database_version_supported()
self.assertTrue(mocked_get_database_version.called)