Fixed #29015 -- Added an exception if the PostgreSQL database name is too long.

This commit is contained in:
priyanshsaxena 2018-01-18 23:45:16 +05:30 committed by Tim Graham
parent 6d1f576945
commit 6b3d292043
2 changed files with 19 additions and 0 deletions

View file

@ -149,6 +149,12 @@ class DatabaseWrapper(BaseDatabaseWrapper):
raise ImproperlyConfigured(
"settings.DATABASES is improperly configured. "
"Please supply the NAME value.")
if len(settings_dict['NAME'] or '') > self.ops.max_name_length():
raise ImproperlyConfigured(
'Database names longer than %d characters are not supported by '
'PostgreSQL. Supply a shorter NAME in settings.DATABASES.'
% self.ops.max_name_length()
)
conn_params = {
'database': settings_dict['NAME'] or 'postgres',
**settings_dict['OPTIONS'],