mirror of
https://github.com/django/django.git
synced 2024-11-29 14:46:18 +01:00
Implemented PostgreSQL version as a cached property.
This commit is contained in:
parent
7b8529d206
commit
21765c0a6c
@ -14,6 +14,7 @@ from django.db.backends.postgresql_psycopg2.creation import DatabaseCreation
|
||||
from django.db.backends.postgresql_psycopg2.version import get_version
|
||||
from django.db.backends.postgresql_psycopg2.introspection import DatabaseIntrospection
|
||||
from django.utils.encoding import force_str
|
||||
from django.utils.functional import cached_property
|
||||
from django.utils.safestring import SafeText, SafeBytes
|
||||
from django.utils import six
|
||||
from django.utils.timezone import utc
|
||||
@ -121,7 +122,6 @@ class DatabaseWrapper(BaseDatabaseWrapper):
|
||||
self.creation = DatabaseCreation(self)
|
||||
self.introspection = DatabaseIntrospection(self)
|
||||
self.validation = BaseDatabaseValidation(self)
|
||||
self._pg_version = None
|
||||
|
||||
def check_constraints(self, table_names=None):
|
||||
"""
|
||||
@ -150,11 +150,9 @@ class DatabaseWrapper(BaseDatabaseWrapper):
|
||||
)
|
||||
raise
|
||||
|
||||
def _get_pg_version(self):
|
||||
if self._pg_version is None:
|
||||
self._pg_version = get_version(self.connection)
|
||||
return self._pg_version
|
||||
pg_version = property(_get_pg_version)
|
||||
@cached_property
|
||||
def pg_version(self):
|
||||
return get_version(self.connection)
|
||||
|
||||
def get_connection_params(self):
|
||||
settings_dict = self.settings_dict
|
||||
@ -202,7 +200,6 @@ class DatabaseWrapper(BaseDatabaseWrapper):
|
||||
self.connection.cursor().execute(
|
||||
self.ops.set_time_zone_sql(), [tz])
|
||||
self.connection.set_isolation_level(self.isolation_level)
|
||||
self._get_pg_version()
|
||||
|
||||
def create_cursor(self):
|
||||
cursor = self.connection.cursor()
|
||||
|
Loading…
Reference in New Issue
Block a user