summaryrefslogtreecommitdiff
path: root/django/db/backends/postgresql
diff options
context:
space:
mode:
authorAnthony Joseph <ajosephau@users.noreply.github.com>2024-10-23 22:13:18 +1100
committerSarah Boyce <42296566+sarahboyce@users.noreply.github.com>2024-10-30 15:54:48 +0100
commit3a8f52fbc6fe2ff646a2da4165497d82117e4a92 (patch)
treeb2f496aadef5091699c8305ba52edc71a88e5a78 /django/db/backends/postgresql
parent97a6a678c406b0049bd17bcd34f1d71d96141994 (diff)
Fixed #35856 -- Added QuerySet.explain() support for MEMORY/SERIALIZE option on PostgreSQL 17+.
Diffstat (limited to 'django/db/backends/postgresql')
-rw-r--r--django/db/backends/postgresql/features.py4
-rw-r--r--django/db/backends/postgresql/operations.py5
2 files changed, 9 insertions, 0 deletions
diff --git a/django/db/backends/postgresql/features.py b/django/db/backends/postgresql/features.py
index 6170b5501a..16653a0519 100644
--- a/django/db/backends/postgresql/features.py
+++ b/django/db/backends/postgresql/features.py
@@ -160,6 +160,10 @@ class DatabaseFeatures(BaseDatabaseFeatures):
def is_postgresql_16(self):
return self.connection.pg_version >= 160000
+ @cached_property
+ def is_postgresql_17(self):
+ return self.connection.pg_version >= 170000
+
supports_unlimited_charfield = True
supports_nulls_distinct_unique_constraints = property(
operator.attrgetter("is_postgresql_15")
diff --git a/django/db/backends/postgresql/operations.py b/django/db/backends/postgresql/operations.py
index 4b179ca83f..d89f81bf7e 100644
--- a/django/db/backends/postgresql/operations.py
+++ b/django/db/backends/postgresql/operations.py
@@ -32,7 +32,9 @@ class DatabaseOperations(BaseDatabaseOperations):
"BUFFERS",
"COSTS",
"GENERIC_PLAN",
+ "MEMORY",
"SETTINGS",
+ "SERIALIZE",
"SUMMARY",
"TIMING",
"VERBOSE",
@@ -365,6 +367,9 @@ class DatabaseOperations(BaseDatabaseOperations):
def explain_query_prefix(self, format=None, **options):
extra = {}
+ if serialize := options.pop("serialize", None):
+ if serialize.upper() in {"TEXT", "BINARY"}:
+ extra["SERIALIZE"] = serialize.upper()
# Normalize options.
if options:
options = {