diff options
author | Hasan Ramezani <hasan.r67@gmail.com> | 2021-12-27 19:04:59 +0100 |
---|---|---|
committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2022-02-18 13:37:49 +0100 |
commit | 9ac3ef59f9538cfb520e3607af743532434d1755 (patch) | |
tree | 62aeb20ea258d03b49fab140b61a40d2634011ae /django/db/backends/postgresql/base.py | |
parent | 737542390af27616d93f86cd418e2d7f3e874b27 (diff) | |
download | django-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.py | 8 |
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() |