Fix #191 need to check for psycopg2.InternalError too

This fix corrects the problem when used with django-simple-import
https://github.com/burke-software/django-simple-import/issues/37
This commit is contained in:
David Burke 2014-11-19 13:04:11 -05:00
parent 1a8680960b
commit d1eb9dd30d
1 changed files with 2 additions and 1 deletions

View File

@ -5,6 +5,7 @@ from django.utils.importlib import import_module
from django.core.exceptions import ImproperlyConfigured, ValidationError
from tenant_schemas.utils import get_public_schema_name, get_limit_set_calls
import django.db.utils
import psycopg2
ORIGINAL_BACKEND = getattr(settings, 'ORIGINAL_BACKEND', 'django.db.backends.postgresql_psycopg2')
@ -123,7 +124,7 @@ class DatabaseWrapper(original_backend.DatabaseWrapper):
# we do not have to worry that it's not the good one
try:
cursor.execute('SET search_path = {0}'.format(','.join(search_paths)))
except django.db.utils.DatabaseError:
except (django.db.utils.DatabaseError, psycopg2.InternalError):
self.search_path_set = False
else:
self.search_path_set = True