mirror of
https://github.com/django/django.git
synced 2025-06-14 07:59:12 +00: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.version import get_version
|
||||||
from django.db.backends.postgresql_psycopg2.introspection import DatabaseIntrospection
|
from django.db.backends.postgresql_psycopg2.introspection import DatabaseIntrospection
|
||||||
from django.utils.encoding import force_str
|
from django.utils.encoding import force_str
|
||||||
|
from django.utils.functional import cached_property
|
||||||
from django.utils.safestring import SafeText, SafeBytes
|
from django.utils.safestring import SafeText, SafeBytes
|
||||||
from django.utils import six
|
from django.utils import six
|
||||||
from django.utils.timezone import utc
|
from django.utils.timezone import utc
|
||||||
@ -121,7 +122,6 @@ class DatabaseWrapper(BaseDatabaseWrapper):
|
|||||||
self.creation = DatabaseCreation(self)
|
self.creation = DatabaseCreation(self)
|
||||||
self.introspection = DatabaseIntrospection(self)
|
self.introspection = DatabaseIntrospection(self)
|
||||||
self.validation = BaseDatabaseValidation(self)
|
self.validation = BaseDatabaseValidation(self)
|
||||||
self._pg_version = None
|
|
||||||
|
|
||||||
def check_constraints(self, table_names=None):
|
def check_constraints(self, table_names=None):
|
||||||
"""
|
"""
|
||||||
@ -150,11 +150,9 @@ class DatabaseWrapper(BaseDatabaseWrapper):
|
|||||||
)
|
)
|
||||||
raise
|
raise
|
||||||
|
|
||||||
def _get_pg_version(self):
|
@cached_property
|
||||||
if self._pg_version is None:
|
def pg_version(self):
|
||||||
self._pg_version = get_version(self.connection)
|
return get_version(self.connection)
|
||||||
return self._pg_version
|
|
||||||
pg_version = property(_get_pg_version)
|
|
||||||
|
|
||||||
def get_connection_params(self):
|
def get_connection_params(self):
|
||||||
settings_dict = self.settings_dict
|
settings_dict = self.settings_dict
|
||||||
@ -202,7 +200,6 @@ class DatabaseWrapper(BaseDatabaseWrapper):
|
|||||||
self.connection.cursor().execute(
|
self.connection.cursor().execute(
|
||||||
self.ops.set_time_zone_sql(), [tz])
|
self.ops.set_time_zone_sql(), [tz])
|
||||||
self.connection.set_isolation_level(self.isolation_level)
|
self.connection.set_isolation_level(self.isolation_level)
|
||||||
self._get_pg_version()
|
|
||||||
|
|
||||||
def create_cursor(self):
|
def create_cursor(self):
|
||||||
cursor = self.connection.cursor()
|
cursor = self.connection.cursor()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user