Skip to content

Commit

Permalink
Fixed #28584 -- Dropped support for SQLite < 3.7.15.
Browse files Browse the repository at this point in the history
  • Loading branch information
timgraham committed Oct 3, 2017
1 parent 51d230e commit 27193ae
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 44 deletions.
12 changes: 3 additions & 9 deletions django/db/backends/sqlite3/features.py
Expand Up @@ -2,8 +2,6 @@
from django.db.backends.base.features import BaseDatabaseFeatures
from django.utils.functional import cached_property

from .base import Database


class DatabaseFeatures(BaseDatabaseFeatures):
# SQLite cannot handle us only partially reading from a cursor's result set
Expand All @@ -30,13 +28,9 @@ class DatabaseFeatures(BaseDatabaseFeatures):
supports_temporal_subtraction = True
ignores_table_name_case = True
supports_cast_with_precision = False
uses_savepoints = Database.sqlite_version_info >= (3, 6, 8)
supports_index_column_ordering = Database.sqlite_version_info >= (3, 3, 0)
can_release_savepoints = uses_savepoints
can_share_in_memory_db = (
Database.__name__ == 'sqlite3.dbapi2' and
Database.sqlite_version_info >= (3, 7, 13)
)
uses_savepoints = True
can_release_savepoints = True
can_share_in_memory_db = True

@cached_property
def supports_stddev(self):
Expand Down
15 changes: 0 additions & 15 deletions django/db/backends/sqlite3/introspection.py
Expand Up @@ -87,21 +87,6 @@ def get_sequences(self, cursor, table_name, table_fields=()):
pk_col = self.get_primary_key_column(cursor, table_name)
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):
"""
Return a dictionary of {field_name: (field_name_other_table, other_table)}
Expand Down
2 changes: 1 addition & 1 deletion docs/ref/contrib/gis/install/index.txt
Expand Up @@ -61,7 +61,7 @@ Database Library Requirements Supported Versions Notes
PostgreSQL GEOS, GDAL, PROJ.4, PostGIS 9.4+ Requires PostGIS.
MySQL GEOS, GDAL 5.6+ Not OGC-compliant; :ref:`limited functionality <mysql-spatial-limitations>`.
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
Expand Down
6 changes: 0 additions & 6 deletions docs/ref/models/indexes.txt
Expand Up @@ -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
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``
--------

Expand Down
10 changes: 5 additions & 5 deletions docs/topics/db/transactions.txt
Expand Up @@ -487,9 +487,9 @@ Savepoints

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
available with the SQLite (≥ 3.6.8), PostgreSQL, Oracle and MySQL (when using
the InnoDB storage engine) backends. Other backends provide the savepoint
functions, but they're empty operations -- they don't actually do anything.
available with the SQLite, PostgreSQL, Oracle, and MySQL (when using the InnoDB
storage engine) backends. Other backends provide the savepoint functions, but
they're empty operations -- they don't actually do anything.

Savepoints aren't especially useful if you are using autocommit, the default
behavior of Django. However, once you open a transaction with :func:`atomic`,
Expand Down Expand Up @@ -582,8 +582,8 @@ Database-specific notes
Savepoints in SQLite
--------------------

While SQLite ≥ 3.6.8 supports savepoints, a flaw in the design of the
:mod:`sqlite3` module makes them hardly usable.
While SQLite supports savepoints, a flaw in the design of the :mod:`sqlite3`
module makes them hardly usable.

When autocommit is enabled, savepoints don't make sense. When it's disabled,
:mod:`sqlite3` commits implicitly before savepoint statements. (In fact, it
Expand Down
2 changes: 1 addition & 1 deletion docs/topics/testing/overview.txt
Expand Up @@ -177,7 +177,7 @@ control the particular collation used by the test database. See the
:doc:`settings documentation </ref/settings>` for details of these
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
with ability to share the database between threads.

Expand Down
8 changes: 1 addition & 7 deletions tests/expressions_case/tests.py
Expand Up @@ -5,7 +5,7 @@
from uuid import UUID

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.expressions import Case, When
from django.test import TestCase
Expand Down Expand Up @@ -296,12 +296,6 @@ def test_combined_expression(self):
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):
self.assertQuerysetEqual(
CaseTestModel.objects.filter(
Expand Down

0 comments on commit 27193ae

Please sign in to comment.