From fd866c25d1665b73aff0d8312c414ae6f69812a3 Mon Sep 17 00:00:00 2001 From: Tim Graham Date: Sat, 30 Sep 2017 14:13:18 -0400 Subject: [PATCH] Fixed #28654 -- Dropped support for SpatiaLite 4.0. --- django/contrib/gis/db/backends/spatialite/base.py | 3 +-- django/contrib/gis/db/backends/spatialite/features.py | 7 ------- django/contrib/gis/db/backends/spatialite/introspection.py | 6 +++--- django/contrib/gis/db/backends/spatialite/operations.py | 5 ++--- docs/ref/contrib/gis/install/geolibs.txt | 3 +-- docs/ref/contrib/gis/install/index.txt | 2 +- docs/releases/2.1.txt | 5 +++++ 7 files changed, 13 insertions(+), 18 deletions(-) diff --git a/django/contrib/gis/db/backends/spatialite/base.py b/django/contrib/gis/db/backends/spatialite/base.py index 7aea4f21ed..c072a4807f 100644 --- a/django/contrib/gis/db/backends/spatialite/base.py +++ b/django/contrib/gis/db/backends/spatialite/base.py @@ -61,5 +61,4 @@ class DatabaseWrapper(SQLiteDatabaseWrapper): with self.cursor() as cursor: cursor.execute("PRAGMA table_info(geometry_columns);") if cursor.fetchall() == []: - arg = "1" if self.features.supports_initspatialmetadata_in_one_transaction else "" - cursor.execute("SELECT InitSpatialMetaData(%s)" % arg) + cursor.execute("SELECT InitSpatialMetaData(1)") diff --git a/django/contrib/gis/db/backends/spatialite/features.py b/django/contrib/gis/db/backends/spatialite/features.py index 319f81c4e1..d29e7876ae 100644 --- a/django/contrib/gis/db/backends/spatialite/features.py +++ b/django/contrib/gis/db/backends/spatialite/features.py @@ -8,13 +8,6 @@ from django.utils.functional import cached_property class DatabaseFeatures(BaseSpatialFeatures, SQLiteDatabaseFeatures): supports_3d_storage = True - @cached_property - def supports_initspatialmetadata_in_one_transaction(self): - # SpatiaLite 4.1+ support initializing all metadata in one transaction - # which can result in a significant performance improvement when - # creating the database. - return self.connection.ops.spatial_version >= (4, 1, 0) - @cached_property def supports_area_geodetic(self): return bool(self.connection.ops.lwgeom_version()) diff --git a/django/contrib/gis/db/backends/spatialite/introspection.py b/django/contrib/gis/db/backends/spatialite/introspection.py index e06cd5a4e1..98fda427d0 100644 --- a/django/contrib/gis/db/backends/spatialite/introspection.py +++ b/django/contrib/gis/db/backends/spatialite/introspection.py @@ -41,9 +41,9 @@ class SpatiaLiteIntrospection(DatabaseIntrospection): # from OGC geom type name to Django field. ogr_type = row[2] if isinstance(ogr_type, int) and ogr_type > 1000: - # SpatiaLite versions >= 4 use the new SFSQL 1.2 offsets - # 1000 (Z), 2000 (M), and 3000 (ZM) to indicate the presence of - # higher dimensional coordinates (M not yet supported by Django). + # SpatiaLite uses SFSQL 1.2 offsets 1000 (Z), 2000 (M), and + # 3000 (ZM) to indicate the presence of higher dimensional + # coordinates (M not yet supported by Django). ogr_type = ogr_type % 1000 + OGRGeomType.wkb25bit field_type = OGRGeomType(ogr_type).django diff --git a/django/contrib/gis/db/backends/spatialite/operations.py b/django/contrib/gis/db/backends/spatialite/operations.py index 3fb821d94e..38abe72a65 100644 --- a/django/contrib/gis/db/backends/spatialite/operations.py +++ b/django/contrib/gis/db/backends/spatialite/operations.py @@ -1,6 +1,5 @@ """ SQL functions reference lists: -https://web.archive.org/web/20130407175746/https://www.gaia-gis.it/gaia-sins/spatialite-sql-4.0.0.html https://www.gaia-gis.it/gaia-sins/spatialite-sql-4.2.1.html """ from django.contrib.gis.db.backends.base.operations import ( @@ -96,8 +95,8 @@ class SpatiaLiteOperations(BaseSpatialOperations, DatabaseOperations): self.connection.settings_dict['NAME'], ) ) from exc - if version < (4, 0, 0): - raise ImproperlyConfigured('GeoDjango only supports SpatiaLite versions 4.0.0 and above.') + if version < (4, 1, 0): + raise ImproperlyConfigured('GeoDjango only supports SpatiaLite versions 4.1.0 and above.') return version def convert_extent(self, box): diff --git a/docs/ref/contrib/gis/install/geolibs.txt b/docs/ref/contrib/gis/install/geolibs.txt index 064f40f11a..1cf6904785 100644 --- a/docs/ref/contrib/gis/install/geolibs.txt +++ b/docs/ref/contrib/gis/install/geolibs.txt @@ -13,7 +13,7 @@ Program Description Required :doc:`GDAL <../gdal>` Geospatial Data Abstraction Library Yes 2.2, 2.1, 2.0, 1.11, 1.10, 1.9 :doc:`GeoIP <../geoip2>` IP-based geolocation library No 2 `PostGIS`__ Spatial extensions for PostgreSQL Yes (PostgreSQL only) 2.3, 2.2, 2.1 -`SpatiaLite`__ Spatial extensions for SQLite Yes (SQLite only) 4.3, 4.2, 4.1, 4.0 +`SpatiaLite`__ Spatial extensions for SQLite Yes (SQLite only) 4.3, 4.2, 4.1 ======================== ==================================== ================================ =================================== Note that older or more recent versions of these libraries *may* also work @@ -32,7 +32,6 @@ totally fine with GeoDjango. Your mileage may vary. PostGIS 2.1.0 2013-08-17 PostGIS 2.2.0 2015-10-17 PostGIS 2.3.0 2016-09-26 - SpatiaLite 4.0.0 2012-11-25 SpatiaLite 4.1.0 2013-06-04 SpatiaLite 4.2.0 2014-07-25 SpatiaLite 4.3.0 2015-09-07 diff --git a/docs/ref/contrib/gis/install/index.txt b/docs/ref/contrib/gis/install/index.txt index 9872f25602..78d3cd6723 100644 --- a/docs/ref/contrib/gis/install/index.txt +++ b/docs/ref/contrib/gis/install/index.txt @@ -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 `. Oracle GEOS, GDAL 12.1+ XE not supported. -SQLite GEOS, GDAL, PROJ.4, SpatiaLite 3.6.+ Requires SpatiaLite 4.0+ +SQLite GEOS, GDAL, PROJ.4, SpatiaLite 3.6.+ Requires SpatiaLite 4.1+ ================== ============================== ================== ========================================= See also `this comparison matrix`__ on the OSGeo Wiki for diff --git a/docs/releases/2.1.txt b/docs/releases/2.1.txt index fa4b407d9a..6a451bdd50 100644 --- a/docs/releases/2.1.txt +++ b/docs/releases/2.1.txt @@ -200,6 +200,11 @@ Database backend API * ... +:mod:`django.contrib.gis` +------------------------- + +* Support for SpatiaLite 4.0 is removed. + Dropped support for MySQL 5.5 -----------------------------