compat: ignore error on checking db vendor (fixes #29926)
compat can be loaded before initialization of db in tests, we must ignore errors at such a time.
This commit is contained in:
parent
a44d45fc24
commit
275b7cd4db
|
@ -4,6 +4,8 @@ import inspect
|
||||||
import django
|
import django
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.db import connection
|
from django.db import connection
|
||||||
|
from django.db.utils import OperationalError
|
||||||
|
from django.core.exceptions import ImproperlyConfigured
|
||||||
|
|
||||||
from django.contrib.auth.tokens import PasswordResetTokenGenerator
|
from django.contrib.auth.tokens import PasswordResetTokenGenerator
|
||||||
|
|
||||||
|
@ -25,9 +27,11 @@ default_token_generator = PasswordResetTokenGenerator()
|
||||||
|
|
||||||
|
|
||||||
def has_postgresql_support():
|
def has_postgresql_support():
|
||||||
if not settings.DATABASES['default'].get('NAME'):
|
try:
|
||||||
|
return connection.vendor == 'postgresql' and connection.pg_version > 90400
|
||||||
|
except (ImproperlyConfigured, OperationalError):
|
||||||
|
# database is not initialized, be conservative
|
||||||
return False
|
return False
|
||||||
return connection.vendor == 'postgresql' and connection.pg_version > 90400
|
|
||||||
|
|
||||||
|
|
||||||
def use_django_native_field():
|
def use_django_native_field():
|
||||||
|
|
Loading…
Reference in New Issue