From e536fa5ce1f2249d171c5890751aea58e51b3849 Mon Sep 17 00:00:00 2001 From: Mariusz Felisiak Date: Thu, 14 May 2020 06:33:00 +0200 Subject: [PATCH] Fixed #31579 -- Dropped support for PostgreSQL 9.5 and PostGIS 2.2. --- django/contrib/gis/db/backends/postgis/operations.py | 2 +- django/contrib/postgres/indexes.py | 4 ---- django/db/backends/postgresql/features.py | 6 ------ docs/ref/contrib/gis/install/geolibs.txt | 3 +-- docs/ref/contrib/gis/install/index.txt | 2 +- docs/ref/databases.txt | 2 +- docs/releases/3.2.txt | 11 +++++++++++ .../migrations/0001_setup_extensions.py | 8 ++------ tests/postgres_tests/test_indexes.py | 12 ------------ tests/postgres_tests/test_search.py | 3 --- 10 files changed, 17 insertions(+), 36 deletions(-) diff --git a/django/contrib/gis/db/backends/postgis/operations.py b/django/contrib/gis/db/backends/postgis/operations.py index f81f5da152..e9bcfc8a30 100644 --- a/django/contrib/gis/db/backends/postgis/operations.py +++ b/django/contrib/gis/db/backends/postgis/operations.py @@ -180,7 +180,7 @@ class PostGISOperations(BaseSpatialOperations, DatabaseOperations): raise ImproperlyConfigured( 'Cannot determine PostGIS version for database "%s" ' 'using command "SELECT postgis_lib_version()". ' - 'GeoDjango requires at least PostGIS version 2.2. ' + 'GeoDjango requires at least PostGIS version 2.3. ' 'Was the database created from a spatial database ' 'template?' % self.connection.settings_dict['NAME'] ) diff --git a/django/contrib/postgres/indexes.py b/django/contrib/postgres/indexes.py index a5ffe94431..91286046e4 100644 --- a/django/contrib/postgres/indexes.py +++ b/django/contrib/postgres/indexes.py @@ -68,10 +68,6 @@ class BloomIndex(PostgresIndex): kwargs['columns'] = self.columns return path, args, kwargs - def check_supported(self, schema_editor): - if not schema_editor.connection.features.has_bloom_index: - raise NotSupportedError('Bloom indexes require PostgreSQL 9.6+.') - def get_with_params(self): with_params = [] if self.length is not None: diff --git a/django/db/backends/postgresql/features.py b/django/db/backends/postgresql/features.py index 00a8009cf2..80cee8e8da 100644 --- a/django/db/backends/postgresql/features.py +++ b/django/db/backends/postgresql/features.py @@ -59,10 +59,6 @@ class DatabaseFeatures(BaseDatabaseFeatures): validates_explain_options = False # A query will error on invalid options. supports_deferrable_unique_constraints = True - @cached_property - def is_postgresql_9_6(self): - return self.connection.pg_version >= 90600 - @cached_property def is_postgresql_10(self): return self.connection.pg_version >= 100000 @@ -75,8 +71,6 @@ class DatabaseFeatures(BaseDatabaseFeatures): def is_postgresql_12(self): return self.connection.pg_version >= 120000 - has_bloom_index = property(operator.attrgetter('is_postgresql_9_6')) has_brin_autosummarize = property(operator.attrgetter('is_postgresql_10')) - has_phraseto_tsquery = property(operator.attrgetter('is_postgresql_9_6')) has_websearch_to_tsquery = property(operator.attrgetter('is_postgresql_11')) supports_table_partitions = property(operator.attrgetter('is_postgresql_10')) diff --git a/docs/ref/contrib/gis/install/geolibs.txt b/docs/ref/contrib/gis/install/geolibs.txt index 1ba1ba0673..74f17d886a 100644 --- a/docs/ref/contrib/gis/install/geolibs.txt +++ b/docs/ref/contrib/gis/install/geolibs.txt @@ -12,7 +12,7 @@ Program Description Required `PROJ`_ Cartographic Projections library Yes (PostgreSQL and SQLite only) 6.x, 5.x, 4.x :doc:`GDAL <../gdal>` Geospatial Data Abstraction Library Yes 3.1, 3.0, 2.4, 2.3, 2.2, 2.1, 2.0 :doc:`GeoIP <../geoip2>` IP-based geolocation library No 2 -`PostGIS`__ Spatial extensions for PostgreSQL Yes (PostgreSQL only) 3.0, 2.5, 2.4, 2.3, 2.2 +`PostGIS`__ Spatial extensions for PostgreSQL Yes (PostgreSQL only) 3.0, 2.5, 2.4, 2.3 `SpatiaLite`__ Spatial extensions for SQLite Yes (SQLite only) 4.3 ======================== ==================================== ================================ =================================== @@ -32,7 +32,6 @@ totally fine with GeoDjango. Your mileage may vary. GDAL 2.4.0 2018-12 GDAL 3.0.0 2019-05 GDAL 3.1.0 2020-05-07 - PostGIS 2.2.0 2015-10-17 PostGIS 2.3.0 2016-09-26 PostGIS 2.4.0 2017-09-30 PostGIS 2.5.0 2018-09-23 diff --git a/docs/ref/contrib/gis/install/index.txt b/docs/ref/contrib/gis/install/index.txt index df536f2937..5242425aaa 100644 --- a/docs/ref/contrib/gis/install/index.txt +++ b/docs/ref/contrib/gis/install/index.txt @@ -58,7 +58,7 @@ supported versions, and any notes for each of the supported database backends: ================== ============================== ================== ========================================= Database Library Requirements Supported Versions Notes ================== ============================== ================== ========================================= -PostgreSQL GEOS, GDAL, PROJ, PostGIS 9.5+ Requires PostGIS. +PostgreSQL GEOS, GDAL, PROJ, PostGIS 9.6+ Requires PostGIS. MySQL GEOS, GDAL 5.6.1+ :ref:`Limited functionality `. Oracle GEOS, GDAL 12.2+ XE not supported. SQLite GEOS, GDAL, PROJ, SpatiaLite 3.8.3+ Requires SpatiaLite 4.3+ diff --git a/docs/ref/databases.txt b/docs/ref/databases.txt index ef384f14e9..d788f2f677 100644 --- a/docs/ref/databases.txt +++ b/docs/ref/databases.txt @@ -103,7 +103,7 @@ below for information on how to set up your database correctly. PostgreSQL notes ================ -Django supports PostgreSQL 9.5 and higher. `psycopg2`_ 2.5.4 or higher is +Django supports PostgreSQL 9.6 and higher. `psycopg2`_ 2.5.4 or higher is required, though the latest release is recommended. .. _psycopg2: https://www.psycopg.org/ diff --git a/docs/releases/3.2.txt b/docs/releases/3.2.txt index 0e0bb4b3bd..9b485b9e28 100644 --- a/docs/releases/3.2.txt +++ b/docs/releases/3.2.txt @@ -224,6 +224,17 @@ backends. * ... +:mod:`django.contrib.gis` +------------------------- + +* Support for PostGIS 2.2 is removed. + +Dropped support for PostgreSQL 9.5 +---------------------------------- + +Upstream support for PostgreSQL 9.5 ends in February 2021. Django 3.2 supports +PostgreSQL 9.6 and higher. + Miscellaneous ------------- diff --git a/tests/postgres_tests/migrations/0001_setup_extensions.py b/tests/postgres_tests/migrations/0001_setup_extensions.py index d0a21791ba..5064f7ff99 100644 --- a/tests/postgres_tests/migrations/0001_setup_extensions.py +++ b/tests/postgres_tests/migrations/0001_setup_extensions.py @@ -1,6 +1,6 @@ from unittest import mock -from django.db import connection, migrations +from django.db import migrations try: from django.contrib.postgres.operations import ( @@ -23,11 +23,7 @@ except ImportError: class Migration(migrations.Migration): operations = [ - ( - BloomExtension() - if getattr(connection.features, 'has_bloom_index', False) - else mock.Mock() - ), + BloomExtension(), BtreeGinExtension(), BtreeGistExtension(), CITextExtension(), diff --git a/tests/postgres_tests/test_indexes.py b/tests/postgres_tests/test_indexes.py index acdf1f4771..0440beda5d 100644 --- a/tests/postgres_tests/test_indexes.py +++ b/tests/postgres_tests/test_indexes.py @@ -260,7 +260,6 @@ class SchemaTests(PostgreSQLTestCase): editor.remove_index(IntegerArrayModel, index) self.assertNotIn(index_name, self.get_constraints(IntegerArrayModel._meta.db_table)) - @skipUnlessDBFeature('has_bloom_index') def test_bloom_index(self): index_name = 'char_field_model_field_bloom' index = BloomIndex(fields=['field'], name=index_name) @@ -272,7 +271,6 @@ class SchemaTests(PostgreSQLTestCase): editor.remove_index(CharFieldModel, index) self.assertNotIn(index_name, self.get_constraints(CharFieldModel._meta.db_table)) - @skipUnlessDBFeature('has_bloom_index') def test_bloom_parameters(self): index_name = 'char_field_model_field_bloom_params' index = BloomIndex(fields=['field'], name=index_name, length=512, columns=[3]) @@ -285,16 +283,6 @@ class SchemaTests(PostgreSQLTestCase): editor.remove_index(CharFieldModel, index) self.assertNotIn(index_name, self.get_constraints(CharFieldModel._meta.db_table)) - def test_bloom_index_not_supported(self): - index_name = 'bloom_index_exception' - index = BloomIndex(fields=['field'], name=index_name) - msg = 'Bloom indexes require PostgreSQL 9.6+.' - with self.assertRaisesMessage(NotSupportedError, msg): - with mock.patch('django.db.backends.postgresql.features.DatabaseFeatures.has_bloom_index', False): - with connection.schema_editor() as editor: - editor.add_index(CharFieldModel, index) - self.assertNotIn(index_name, self.get_constraints(CharFieldModel._meta.db_table)) - def test_brin_index(self): index_name = 'char_field_model_field_brin' index = BrinIndex(fields=['field'], name=index_name, pages_per_range=4) diff --git a/tests/postgres_tests/test_search.py b/tests/postgres_tests/test_search.py index f6c3031bd4..65ee9ffa20 100644 --- a/tests/postgres_tests/test_search.py +++ b/tests/postgres_tests/test_search.py @@ -195,7 +195,6 @@ class MultipleFieldsTest(GrailTestData, PostgreSQLTestCase): ).filter(search=str(self.crowd.id)) self.assertSequenceEqual(searched, [self.crowd]) - @skipUnlessDBFeature('has_phraseto_tsquery') def test_phrase_search(self): line_qs = Line.objects.annotate(search=SearchVector('dialogue')) searched = line_qs.filter(search=SearchQuery('burned body his away', search_type='phrase')) @@ -203,7 +202,6 @@ class MultipleFieldsTest(GrailTestData, PostgreSQLTestCase): searched = line_qs.filter(search=SearchQuery('his body burned away', search_type='phrase')) self.assertSequenceEqual(searched, [self.verse1]) - @skipUnlessDBFeature('has_phraseto_tsquery') def test_phrase_search_with_config(self): line_qs = Line.objects.annotate( search=SearchVector('scene__setting', 'dialogue', config='french'), @@ -386,7 +384,6 @@ class TestCombinations(GrailTestData, PostgreSQLTestCase): ) self.assertSequenceEqual(searched, [self.verse2]) - @skipUnlessDBFeature('has_phraseto_tsquery') def test_combine_raw_phrase(self): searched = Line.objects.filter( dialogue__search=(