Fixed #28584 -- Dropped support for SQLite < 3.7.15.
This commit is contained in:
parent
51d230e00b
commit
27193aea00
|
@ -2,8 +2,6 @@ from django.db import utils
|
||||||
from django.db.backends.base.features import BaseDatabaseFeatures
|
from django.db.backends.base.features import BaseDatabaseFeatures
|
||||||
from django.utils.functional import cached_property
|
from django.utils.functional import cached_property
|
||||||
|
|
||||||
from .base import Database
|
|
||||||
|
|
||||||
|
|
||||||
class DatabaseFeatures(BaseDatabaseFeatures):
|
class DatabaseFeatures(BaseDatabaseFeatures):
|
||||||
# SQLite cannot handle us only partially reading from a cursor's result set
|
# SQLite cannot handle us only partially reading from a cursor's result set
|
||||||
|
@ -30,13 +28,9 @@ class DatabaseFeatures(BaseDatabaseFeatures):
|
||||||
supports_temporal_subtraction = True
|
supports_temporal_subtraction = True
|
||||||
ignores_table_name_case = True
|
ignores_table_name_case = True
|
||||||
supports_cast_with_precision = False
|
supports_cast_with_precision = False
|
||||||
uses_savepoints = Database.sqlite_version_info >= (3, 6, 8)
|
uses_savepoints = True
|
||||||
supports_index_column_ordering = Database.sqlite_version_info >= (3, 3, 0)
|
can_release_savepoints = True
|
||||||
can_release_savepoints = uses_savepoints
|
can_share_in_memory_db = True
|
||||||
can_share_in_memory_db = (
|
|
||||||
Database.__name__ == 'sqlite3.dbapi2' and
|
|
||||||
Database.sqlite_version_info >= (3, 7, 13)
|
|
||||||
)
|
|
||||||
|
|
||||||
@cached_property
|
@cached_property
|
||||||
def supports_stddev(self):
|
def supports_stddev(self):
|
||||||
|
|
|
@ -87,21 +87,6 @@ class DatabaseIntrospection(BaseDatabaseIntrospection):
|
||||||
pk_col = self.get_primary_key_column(cursor, table_name)
|
pk_col = self.get_primary_key_column(cursor, table_name)
|
||||||
return [{'table': table_name, 'column': pk_col}]
|
return [{'table': table_name, 'column': pk_col}]
|
||||||
|
|
||||||
def column_name_converter(self, name):
|
|
||||||
"""
|
|
||||||
SQLite will in some cases, e.g. when returning columns from views and
|
|
||||||
subselects, return column names in 'alias."column"' format instead of
|
|
||||||
simply 'column'.
|
|
||||||
|
|
||||||
Affects SQLite < 3.7.15, fixed by http://www.sqlite.org/src/info/5526e0aa3c
|
|
||||||
"""
|
|
||||||
# TODO: remove when SQLite < 3.7.15 is sufficiently old.
|
|
||||||
# 3.7.13 ships in Debian stable as of 2014-03-21.
|
|
||||||
if self.connection.Database.sqlite_version_info < (3, 7, 15):
|
|
||||||
return name.split('.')[-1].strip('"')
|
|
||||||
else:
|
|
||||||
return name
|
|
||||||
|
|
||||||
def get_relations(self, cursor, table_name):
|
def get_relations(self, cursor, table_name):
|
||||||
"""
|
"""
|
||||||
Return a dictionary of {field_name: (field_name_other_table, other_table)}
|
Return a dictionary of {field_name: (field_name_other_table, other_table)}
|
||||||
|
|
|
@ -61,7 +61,7 @@ Database Library Requirements Supported Versions Notes
|
||||||
PostgreSQL GEOS, GDAL, PROJ.4, PostGIS 9.4+ Requires PostGIS.
|
PostgreSQL GEOS, GDAL, PROJ.4, PostGIS 9.4+ Requires PostGIS.
|
||||||
MySQL GEOS, GDAL 5.6+ Not OGC-compliant; :ref:`limited functionality <mysql-spatial-limitations>`.
|
MySQL GEOS, GDAL 5.6+ Not OGC-compliant; :ref:`limited functionality <mysql-spatial-limitations>`.
|
||||||
Oracle GEOS, GDAL 12.1+ XE not supported.
|
Oracle GEOS, GDAL 12.1+ XE not supported.
|
||||||
SQLite GEOS, GDAL, PROJ.4, SpatiaLite 3.6.+ Requires SpatiaLite 4.1+
|
SQLite GEOS, GDAL, PROJ.4, SpatiaLite 3.7.15+ Requires SpatiaLite 4.1+
|
||||||
================== ============================== ================== =========================================
|
================== ============================== ================== =========================================
|
||||||
|
|
||||||
See also `this comparison matrix`__ on the OSGeo Wiki for
|
See also `this comparison matrix`__ on the OSGeo Wiki for
|
||||||
|
|
|
@ -40,12 +40,6 @@ For example ``Index(fields=['headline', '-pub_date'])`` would create SQL with
|
||||||
``(headline, pub_date DESC)``. Index ordering isn't supported on MySQL. In that
|
``(headline, pub_date DESC)``. Index ordering isn't supported on MySQL. In that
|
||||||
case, a descending index is created as a normal index.
|
case, a descending index is created as a normal index.
|
||||||
|
|
||||||
.. admonition:: Support for column ordering on SQLite
|
|
||||||
|
|
||||||
Column ordering is supported on SQLite 3.3.0+ and only for some database
|
|
||||||
file formats. Refer to the `SQLite docs
|
|
||||||
<https://www.sqlite.org/lang_createindex.html>`_ for specifics.
|
|
||||||
|
|
||||||
``name``
|
``name``
|
||||||
--------
|
--------
|
||||||
|
|
||||||
|
|
|
@ -487,9 +487,9 @@ Savepoints
|
||||||
|
|
||||||
A savepoint is a marker within a transaction that enables you to roll back
|
A savepoint is a marker within a transaction that enables you to roll back
|
||||||
part of a transaction, rather than the full transaction. Savepoints are
|
part of a transaction, rather than the full transaction. Savepoints are
|
||||||
available with the SQLite (≥ 3.6.8), PostgreSQL, Oracle and MySQL (when using
|
available with the SQLite, PostgreSQL, Oracle, and MySQL (when using the InnoDB
|
||||||
the InnoDB storage engine) backends. Other backends provide the savepoint
|
storage engine) backends. Other backends provide the savepoint functions, but
|
||||||
functions, but they're empty operations -- they don't actually do anything.
|
they're empty operations -- they don't actually do anything.
|
||||||
|
|
||||||
Savepoints aren't especially useful if you are using autocommit, the default
|
Savepoints aren't especially useful if you are using autocommit, the default
|
||||||
behavior of Django. However, once you open a transaction with :func:`atomic`,
|
behavior of Django. However, once you open a transaction with :func:`atomic`,
|
||||||
|
@ -582,8 +582,8 @@ Database-specific notes
|
||||||
Savepoints in SQLite
|
Savepoints in SQLite
|
||||||
--------------------
|
--------------------
|
||||||
|
|
||||||
While SQLite ≥ 3.6.8 supports savepoints, a flaw in the design of the
|
While SQLite supports savepoints, a flaw in the design of the :mod:`sqlite3`
|
||||||
:mod:`sqlite3` module makes them hardly usable.
|
module makes them hardly usable.
|
||||||
|
|
||||||
When autocommit is enabled, savepoints don't make sense. When it's disabled,
|
When autocommit is enabled, savepoints don't make sense. When it's disabled,
|
||||||
:mod:`sqlite3` commits implicitly before savepoint statements. (In fact, it
|
:mod:`sqlite3` commits implicitly before savepoint statements. (In fact, it
|
||||||
|
|
|
@ -177,7 +177,7 @@ control the particular collation used by the test database. See the
|
||||||
:doc:`settings documentation </ref/settings>` for details of these
|
:doc:`settings documentation </ref/settings>` for details of these
|
||||||
and other advanced settings.
|
and other advanced settings.
|
||||||
|
|
||||||
If using an SQLite in-memory database with SQLite 3.7.13+, `shared cache
|
If using an SQLite in-memory database with SQLite, `shared cache
|
||||||
<https://www.sqlite.org/sharedcache.html>`_ is enabled, so you can write tests
|
<https://www.sqlite.org/sharedcache.html>`_ is enabled, so you can write tests
|
||||||
with ability to share the database between threads.
|
with ability to share the database between threads.
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ from operator import attrgetter, itemgetter
|
||||||
from uuid import UUID
|
from uuid import UUID
|
||||||
|
|
||||||
from django.core.exceptions import FieldError
|
from django.core.exceptions import FieldError
|
||||||
from django.db import connection, models
|
from django.db import models
|
||||||
from django.db.models import F, Max, Min, Q, Sum, Value
|
from django.db.models import F, Max, Min, Q, Sum, Value
|
||||||
from django.db.models.expressions import Case, When
|
from django.db.models.expressions import Case, When
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
|
@ -296,12 +296,6 @@ class CaseExpressionTests(TestCase):
|
||||||
transform=attrgetter('integer', 'test')
|
transform=attrgetter('integer', 'test')
|
||||||
)
|
)
|
||||||
|
|
||||||
if connection.vendor == 'sqlite' and connection.Database.sqlite_version_info < (3, 7, 0):
|
|
||||||
# There is a bug in sqlite < 3.7.0, where placeholder order is lost.
|
|
||||||
# Thus, the above query returns <condition_value> + <result_value>
|
|
||||||
# for each matching case instead of <result_value> + 1 (#24148).
|
|
||||||
test_combined_expression = unittest.expectedFailure(test_combined_expression)
|
|
||||||
|
|
||||||
def test_in_subquery(self):
|
def test_in_subquery(self):
|
||||||
self.assertQuerysetEqual(
|
self.assertQuerysetEqual(
|
||||||
CaseTestModel.objects.filter(
|
CaseTestModel.objects.filter(
|
||||||
|
|
Loading…
Reference in New Issue