mirror of
				https://github.com/django/django.git
				synced 2025-10-31 09:41:08 +00:00 
			
		
		
		
	[2.1.x] Refs #29015 -- Added database name to PostgreSQL database name too long exception.
Backport of bf17f5e884 from master
			
			
This commit is contained in:
		| @@ -151,9 +151,13 @@ class DatabaseWrapper(BaseDatabaseWrapper): | |||||||
|                 "Please supply the NAME value.") |                 "Please supply the NAME value.") | ||||||
|         if len(settings_dict['NAME'] or '') > self.ops.max_name_length(): |         if len(settings_dict['NAME'] or '') > self.ops.max_name_length(): | ||||||
|             raise ImproperlyConfigured( |             raise ImproperlyConfigured( | ||||||
|                 'Database names longer than %d characters are not supported by ' |                 "The database name '%s' (%d characters) is longer than " | ||||||
|                 'PostgreSQL. Supply a shorter NAME in settings.DATABASES.' |                 "PostgreSQL's limit of %d characters. Supply a shorter NAME " | ||||||
|                 % self.ops.max_name_length() |                 "in settings.DATABASES." % ( | ||||||
|  |                     settings_dict['NAME'], | ||||||
|  |                     len(settings_dict['NAME']), | ||||||
|  |                     self.ops.max_name_length(), | ||||||
|  |                 ) | ||||||
|             ) |             ) | ||||||
|         conn_params = { |         conn_params = { | ||||||
|             'database': settings_dict['NAME'] or 'postgres', |             'database': settings_dict['NAME'] or 'postgres', | ||||||
|   | |||||||
| @@ -48,9 +48,10 @@ class Tests(TestCase): | |||||||
|         max_name_length = connection.ops.max_name_length() |         max_name_length = connection.ops.max_name_length() | ||||||
|         settings['NAME'] = 'a' + (max_name_length * 'a') |         settings['NAME'] = 'a' + (max_name_length * 'a') | ||||||
|         msg = ( |         msg = ( | ||||||
|             'Database names longer than %d characters are not supported by ' |             "The database name '%s' (%d characters) is longer than " | ||||||
|             'PostgreSQL. Supply a shorter NAME in settings.DATABASES.' |             "PostgreSQL's limit of %s characters. Supply a shorter NAME in " | ||||||
|         ) % max_name_length |             "settings.DATABASES." | ||||||
|  |         ) % (settings['NAME'], max_name_length + 1, max_name_length) | ||||||
|         with self.assertRaisesMessage(ImproperlyConfigured, msg): |         with self.assertRaisesMessage(ImproperlyConfigured, msg): | ||||||
|             DatabaseWrapper(settings).get_connection_params() |             DatabaseWrapper(settings).get_connection_params() | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user