mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Fixed #34851 -- Dropped support for PostgreSQL 12 and PostGIS 2.5.
This commit is contained in:
@@ -404,12 +404,12 @@ class Tests(TestCase):
|
||||
|
||||
def test_get_database_version(self):
|
||||
new_connection = connection.copy()
|
||||
new_connection.pg_version = 110009
|
||||
self.assertEqual(new_connection.get_database_version(), (11, 9))
|
||||
new_connection.pg_version = 130009
|
||||
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):
|
||||
msg = "PostgreSQL 12 or later is required (found 11)."
|
||||
msg = "PostgreSQL 13 or later is required (found 12)."
|
||||
with self.assertRaisesMessage(NotSupportedError, msg):
|
||||
connection.check_database_version_supported()
|
||||
self.assertTrue(mocked_get_database_version.called)
|
||||
|
||||
@@ -3,16 +3,10 @@ from django.db import connection, migrations
|
||||
if connection.features.supports_raster:
|
||||
from django.contrib.postgres.operations import CreateExtension
|
||||
|
||||
pg_version = connection.ops.postgis_version_tuple()
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
# PostGIS 3+ requires postgis_raster extension.
|
||||
if pg_version[1:] >= (3,):
|
||||
operations = [
|
||||
CreateExtension("postgis_raster"),
|
||||
]
|
||||
else:
|
||||
operations = []
|
||||
operations = [
|
||||
CreateExtension("postgis_raster"),
|
||||
]
|
||||
|
||||
else:
|
||||
|
||||
|
||||
@@ -3,16 +3,10 @@ from django.db import connection, migrations
|
||||
if connection.features.supports_raster:
|
||||
from django.contrib.postgres.operations import CreateExtension
|
||||
|
||||
pg_version = connection.ops.postgis_version_tuple()
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
# PostGIS 3+ requires postgis_raster extension.
|
||||
if pg_version[1:] >= (3,):
|
||||
operations = [
|
||||
CreateExtension("postgis_raster"),
|
||||
]
|
||||
else:
|
||||
operations = []
|
||||
operations = [
|
||||
CreateExtension("postgis_raster"),
|
||||
]
|
||||
|
||||
else:
|
||||
|
||||
|
||||
@@ -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 (
|
||||
@@ -9,7 +9,6 @@ try:
|
||||
BtreeGistExtension,
|
||||
CITextExtension,
|
||||
CreateExtension,
|
||||
CryptoExtension,
|
||||
HStoreExtension,
|
||||
TrigramExtension,
|
||||
UnaccentExtension,
|
||||
@@ -23,11 +22,6 @@ except ImportError:
|
||||
HStoreExtension = mock.Mock()
|
||||
TrigramExtension = 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):
|
||||
@@ -39,8 +33,6 @@ class Migration(migrations.Migration):
|
||||
# Ensure CreateExtension quotes extension names by creating one with a
|
||||
# dash in its name.
|
||||
CreateExtension("uuid-ossp"),
|
||||
# CryptoExtension is required for RandomUUID() on PostgreSQL < 13.
|
||||
CryptoExtension() if needs_crypto_extension else mock.Mock(),
|
||||
HStoreExtension(),
|
||||
TrigramExtension(),
|
||||
UnaccentExtension(),
|
||||
|
||||
@@ -83,9 +83,8 @@ class ExplainTests(TestCase):
|
||||
{"verbose": False, "timing": False, "analyze": True},
|
||||
{"summary": 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:
|
||||
with self.subTest(**options), transaction.atomic():
|
||||
with CaptureQueriesContext(connection) as captured_queries:
|
||||
|
||||
Reference in New Issue
Block a user