summaryrefslogtreecommitdiff
path: root/django/db/backends/postgresql/base.py
diff options
context:
space:
mode:
authorHasan Ramezani <hasan.r67@gmail.com>2021-12-27 19:04:59 +0100
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2022-02-18 13:37:49 +0100
commit9ac3ef59f9538cfb520e3607af743532434d1755 (patch)
tree62aeb20ea258d03b49fab140b61a40d2634011ae /django/db/backends/postgresql/base.py
parent737542390af27616d93f86cd418e2d7f3e874b27 (diff)
downloaddjango-9ac3ef59f9538cfb520e3607af743532434d1755.tar.gz
Fixed #33379 -- Added minimum database version checks.
Thanks Tim Graham for the review.
Diffstat (limited to 'django/db/backends/postgresql/base.py')
-rw-r--r--django/db/backends/postgresql/base.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/django/db/backends/postgresql/base.py b/django/db/backends/postgresql/base.py
index 92f393227e..630da22964 100644
--- a/django/db/backends/postgresql/base.py
+++ b/django/db/backends/postgresql/base.py
@@ -153,6 +153,13 @@ class DatabaseWrapper(BaseDatabaseWrapper):
# PostgreSQL backend-specific attributes.
_named_cursor_idx = 0
+ def get_database_version(self):
+ """
+ Return a tuple of the database's version.
+ E.g. for pg_version 120004, return (12, 4).
+ """
+ return divmod(self.pg_version, 10000)
+
def get_connection_params(self):
settings_dict = self.settings_dict
# None may be used to connect to the default 'postgres' db
@@ -236,6 +243,7 @@ class DatabaseWrapper(BaseDatabaseWrapper):
return False
def init_connection_state(self):
+ super().init_connection_state()
self.connection.set_client_encoding("UTF8")
timezone_changed = self.ensure_timezone()