1
0
mirror of https://github.com/django/django.git synced 2025-06-04 19:19:13 +00:00

Fixed #34851 -- Dropped support for PostgreSQL 12 and PostGIS 2.5.

This commit is contained in:
Mariusz Felisiak 2023-09-20 13:45:51 +02:00 committed by GitHub
parent 0b506bfe1a
commit 2c6ebb65c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 32 additions and 47 deletions

View File

@ -203,7 +203,7 @@ class PostGISOperations(BaseSpatialOperations, DatabaseOperations):
raise ImproperlyConfigured( raise ImproperlyConfigured(
'Cannot determine PostGIS version for database "%s" ' 'Cannot determine PostGIS version for database "%s" '
'using command "SELECT postgis_lib_version()". ' 'using command "SELECT postgis_lib_version()". '
"GeoDjango requires at least PostGIS version 2.5. " "GeoDjango requires at least PostGIS version 3.0. "
"Was the database created from a spatial database " "Was the database created from a spatial database "
"template?" % self.connection.settings_dict["NAME"] "template?" % self.connection.settings_dict["NAME"]
) )

View File

@ -7,7 +7,7 @@ from django.utils.functional import cached_property
class DatabaseFeatures(BaseDatabaseFeatures): class DatabaseFeatures(BaseDatabaseFeatures):
minimum_database_version = (12,) minimum_database_version = (13,)
allows_group_by_selected_pks = True allows_group_by_selected_pks = True
can_return_columns_from_insert = True can_return_columns_from_insert = True
can_return_rows_from_bulk_insert = True can_return_rows_from_bulk_insert = True
@ -126,10 +126,6 @@ class DatabaseFeatures(BaseDatabaseFeatures):
"PositiveSmallIntegerField": "SmallIntegerField", "PositiveSmallIntegerField": "SmallIntegerField",
} }
@cached_property
def is_postgresql_13(self):
return self.connection.pg_version >= 130000
@cached_property @cached_property
def is_postgresql_14(self): def is_postgresql_14(self):
return self.connection.pg_version >= 140000 return self.connection.pg_version >= 140000

View File

@ -12,7 +12,7 @@ Program Description Required
`PROJ`_ Cartographic Projections library Yes (PostgreSQL and SQLite only) 9.x, 8.x, 7.x, 6.x, 5.x `PROJ`_ Cartographic Projections library Yes (PostgreSQL and SQLite only) 9.x, 8.x, 7.x, 6.x, 5.x
:doc:`GDAL <../gdal>` Geospatial Data Abstraction Library Yes 3.7, 3.6, 3.5, 3.4, 3.3, 3.2, 3.1, 3.0, 2.4 :doc:`GDAL <../gdal>` Geospatial Data Abstraction Library Yes 3.7, 3.6, 3.5, 3.4, 3.3, 3.2, 3.1, 3.0, 2.4
:doc:`GeoIP <../geoip2>` IP-based geolocation library No 2 :doc:`GeoIP <../geoip2>` IP-based geolocation library No 2
`PostGIS`__ Spatial extensions for PostgreSQL Yes (PostgreSQL only) 3.4, 3.3, 3.2, 3.1, 3.0, 2.5 `PostGIS`__ Spatial extensions for PostgreSQL Yes (PostgreSQL only) 3.4, 3.3, 3.2, 3.1, 3.0
`SpatiaLite`__ Spatial extensions for SQLite Yes (SQLite only) 5.0, 4.3 `SpatiaLite`__ Spatial extensions for SQLite Yes (SQLite only) 5.0, 4.3
======================== ==================================== ================================ =========================================== ======================== ==================================== ================================ ===========================================
@ -35,7 +35,6 @@ totally fine with GeoDjango. Your mileage may vary.
GDAL 3.5.0 2022-05-13 GDAL 3.5.0 2022-05-13
GDAL 3.6.0 2022-11-03 GDAL 3.6.0 2022-11-03
GDAL 3.7.0 2023-05-10 GDAL 3.7.0 2023-05-10
PostGIS 2.5.0 2018-09-23
PostGIS 3.0.0 2019-10-20 PostGIS 3.0.0 2019-10-20
PostGIS 3.1.0 2020-12-18 PostGIS 3.1.0 2020-12-18
PostGIS 3.2.0 2021-12-18 PostGIS 3.2.0 2021-12-18

View File

@ -56,7 +56,7 @@ supported versions, and any notes for each of the supported database backends:
================== ============================== ================== ========================================= ================== ============================== ================== =========================================
Database Library Requirements Supported Versions Notes Database Library Requirements Supported Versions Notes
================== ============================== ================== ========================================= ================== ============================== ================== =========================================
PostgreSQL GEOS, GDAL, PROJ, PostGIS 12+ Requires PostGIS. PostgreSQL GEOS, GDAL, PROJ, PostGIS 13+ Requires PostGIS.
MySQL GEOS, GDAL 8.0.11+ :ref:`Limited functionality <mysql-spatial-limitations>`. MySQL GEOS, GDAL 8.0.11+ :ref:`Limited functionality <mysql-spatial-limitations>`.
Oracle GEOS, GDAL 19+ XE not supported. Oracle GEOS, GDAL 19+ XE not supported.
SQLite GEOS, GDAL, PROJ, SpatiaLite 3.27.0+ Requires SpatiaLite 4.3+ SQLite GEOS, GDAL, PROJ, SpatiaLite 3.27.0+ Requires SpatiaLite 4.3+

View File

@ -30,7 +30,7 @@ Post-installation
Creating a spatial database Creating a spatial database
--------------------------- ---------------------------
PostGIS 2 includes an extension for PostgreSQL that's used to enable spatial PostGIS includes an extension for PostgreSQL that's used to enable spatial
functionality: functionality:
.. code-block:: shell .. code-block:: shell
@ -50,9 +50,9 @@ process. An alternative is to use a migration operation in your project::
class Migration(migrations.Migration): class Migration(migrations.Migration):
operations = [CreateExtension("postgis"), ...] operations = [CreateExtension("postgis"), ...]
If you plan to use PostGIS raster functionality on PostGIS 3+, you should also If you plan to use PostGIS raster functionality, you should also activate the
activate the ``postgis_raster`` extension. You can install the extension using ``postgis_raster`` extension. You can install the extension using the
the :class:`~django.contrib.postgres.operations.CreateExtension` migration :class:`~django.contrib.postgres.operations.CreateExtension` migration
operation, or directly by running ``CREATE EXTENSION postgis_raster;``. operation, or directly by running ``CREATE EXTENSION postgis_raster;``.
GeoDjango does not currently leverage any `PostGIS topology functionality`__. GeoDjango does not currently leverage any `PostGIS topology functionality`__.

View File

@ -114,7 +114,7 @@ below for information on how to set up your database correctly.
PostgreSQL notes PostgreSQL notes
================ ================
Django supports PostgreSQL 12 and higher. `psycopg`_ 3.1.8+ or `psycopg2`_ Django supports PostgreSQL 13 and higher. `psycopg`_ 3.1.8+ or `psycopg2`_
2.8.4+ is required, though the latest `psycopg`_ 3.1.8+ is recommended. 2.8.4+ is required, though the latest `psycopg`_ 3.1.8+ is recommended.
.. note:: .. note::

View File

@ -228,12 +228,23 @@ backends.
* ... * ...
:mod:`django.contrib.gis`
-------------------------
* Support for PostGIS 2.5 is removed.
Dropped support for MariaDB 10.4 Dropped support for MariaDB 10.4
-------------------------------- --------------------------------
Upstream support for MariaDB 10.4 ends in June 2024. Django 5.1 supports Upstream support for MariaDB 10.4 ends in June 2024. Django 5.1 supports
MariaDB 10.5 and higher. MariaDB 10.5 and higher.
Dropped support for PostgreSQL 12
---------------------------------
Upstream support for PostgreSQL 12 ends in November 2024. Django 5.1 supports
PostgreSQL 13 and higher.
Miscellaneous Miscellaneous
------------- -------------

View File

@ -404,12 +404,12 @@ class Tests(TestCase):
def test_get_database_version(self): def test_get_database_version(self):
new_connection = connection.copy() new_connection = connection.copy()
new_connection.pg_version = 110009 new_connection.pg_version = 130009
self.assertEqual(new_connection.get_database_version(), (11, 9)) self.assertEqual(new_connection.get_database_version(), (13, 9))
@mock.patch.object(connection, "get_database_version", return_value=(11,)) @mock.patch.object(connection, "get_database_version", return_value=(12,))
def test_check_database_version_supported(self, mocked_get_database_version): def test_check_database_version_supported(self, mocked_get_database_version):
msg = "PostgreSQL 12 or later is required (found 11)." msg = "PostgreSQL 13 or later is required (found 12)."
with self.assertRaisesMessage(NotSupportedError, msg): with self.assertRaisesMessage(NotSupportedError, msg):
connection.check_database_version_supported() connection.check_database_version_supported()
self.assertTrue(mocked_get_database_version.called) self.assertTrue(mocked_get_database_version.called)

View File

@ -3,16 +3,10 @@ from django.db import connection, migrations
if connection.features.supports_raster: if connection.features.supports_raster:
from django.contrib.postgres.operations import CreateExtension from django.contrib.postgres.operations import CreateExtension
pg_version = connection.ops.postgis_version_tuple()
class Migration(migrations.Migration): class Migration(migrations.Migration):
# PostGIS 3+ requires postgis_raster extension. operations = [
if pg_version[1:] >= (3,): CreateExtension("postgis_raster"),
operations = [ ]
CreateExtension("postgis_raster"),
]
else:
operations = []
else: else:

View File

@ -3,16 +3,10 @@ from django.db import connection, migrations
if connection.features.supports_raster: if connection.features.supports_raster:
from django.contrib.postgres.operations import CreateExtension from django.contrib.postgres.operations import CreateExtension
pg_version = connection.ops.postgis_version_tuple()
class Migration(migrations.Migration): class Migration(migrations.Migration):
# PostGIS 3+ requires postgis_raster extension. operations = [
if pg_version[1:] >= (3,): CreateExtension("postgis_raster"),
operations = [ ]
CreateExtension("postgis_raster"),
]
else:
operations = []
else: else:

View File

@ -1,6 +1,6 @@
from unittest import mock from unittest import mock
from django.db import connection, migrations from django.db import migrations
try: try:
from django.contrib.postgres.operations import ( from django.contrib.postgres.operations import (
@ -9,7 +9,6 @@ try:
BtreeGistExtension, BtreeGistExtension,
CITextExtension, CITextExtension,
CreateExtension, CreateExtension,
CryptoExtension,
HStoreExtension, HStoreExtension,
TrigramExtension, TrigramExtension,
UnaccentExtension, UnaccentExtension,
@ -23,11 +22,6 @@ except ImportError:
HStoreExtension = mock.Mock() HStoreExtension = mock.Mock()
TrigramExtension = mock.Mock() TrigramExtension = mock.Mock()
UnaccentExtension = mock.Mock() UnaccentExtension = mock.Mock()
needs_crypto_extension = False
else:
needs_crypto_extension = (
connection.vendor == "postgresql" and not connection.features.is_postgresql_13
)
class Migration(migrations.Migration): class Migration(migrations.Migration):
@ -39,8 +33,6 @@ class Migration(migrations.Migration):
# Ensure CreateExtension quotes extension names by creating one with a # Ensure CreateExtension quotes extension names by creating one with a
# dash in its name. # dash in its name.
CreateExtension("uuid-ossp"), CreateExtension("uuid-ossp"),
# CryptoExtension is required for RandomUUID() on PostgreSQL < 13.
CryptoExtension() if needs_crypto_extension else mock.Mock(),
HStoreExtension(), HStoreExtension(),
TrigramExtension(), TrigramExtension(),
UnaccentExtension(), UnaccentExtension(),

View File

@ -83,9 +83,8 @@ class ExplainTests(TestCase):
{"verbose": False, "timing": False, "analyze": True}, {"verbose": False, "timing": False, "analyze": True},
{"summary": True}, {"summary": True},
{"settings": True}, {"settings": True},
{"analyze": True, "wal": True},
] ]
if connection.features.is_postgresql_13:
test_options.append({"analyze": True, "wal": True})
for options in test_options: for options in test_options:
with self.subTest(**options), transaction.atomic(): with self.subTest(**options), transaction.atomic():
with CaptureQueriesContext(connection) as captured_queries: with CaptureQueriesContext(connection) as captured_queries: