diff options
Diffstat (limited to 'django/db/backends/postgresql_psycopg2')
| -rw-r--r-- | django/db/backends/postgresql_psycopg2/base.py | 3 | ||||
| -rw-r--r-- | django/db/backends/postgresql_psycopg2/operations.py | 3 |
2 files changed, 3 insertions, 3 deletions
diff --git a/django/db/backends/postgresql_psycopg2/base.py b/django/db/backends/postgresql_psycopg2/base.py index 831ad84843..85a0991402 100644 --- a/django/db/backends/postgresql_psycopg2/base.py +++ b/django/db/backends/postgresql_psycopg2/base.py @@ -152,7 +152,8 @@ class DatabaseWrapper(BaseDatabaseWrapper): @cached_property def pg_version(self): - return get_version(self.connection) + with self.temporary_connection(): + return get_version(self.connection) def get_connection_params(self): settings_dict = self.settings_dict diff --git a/django/db/backends/postgresql_psycopg2/operations.py b/django/db/backends/postgresql_psycopg2/operations.py index 8e87ed539f..56535e0865 100644 --- a/django/db/backends/postgresql_psycopg2/operations.py +++ b/django/db/backends/postgresql_psycopg2/operations.py @@ -195,8 +195,7 @@ class DatabaseOperations(BaseDatabaseOperations): NotImplementedError if this is the database in use. """ if aggregate.sql_function in ('STDDEV_POP', 'VAR_POP'): - pg_version = self.connection.pg_version - if pg_version >= 80200 and pg_version <= 80204: + if 80200 <= self.connection.pg_version <= 80204: raise NotImplementedError('PostgreSQL 8.2 to 8.2.4 is known to have a faulty implementation of %s. Please upgrade your version of PostgreSQL.' % aggregate.sql_function) def max_name_length(self): |
