1
0
mirror of https://github.com/django/django.git synced 2025-02-09 00:45:23 +00:00

Fixed #25055 -- Made m2m long name testing friendlier for 3rd party databases.

This commit is contained in:
Michael Manfre 2015-07-02 22:09:51 -04:00 committed by Tim Graham
parent 3353684102
commit f9c3587b51

View File

@ -328,17 +328,21 @@ class FieldNamesTests(IsolatedModelsTestCase):
# First error because of M2M field set on the model with long name. # First error because of M2M field set on the model with long name.
m2m_long_name = "verylongmodelnamezzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz_id" m2m_long_name = "verylongmodelnamezzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz_id"
expected = [ if self.max_column_name_length > len(m2m_long_name):
Error( # Some databases support names longer than the test name.
'Autogenerated column name too long for M2M field "%s". ' expected = []
'Maximum length is "%s" for database "%s".' else:
% (m2m_long_name, self.max_column_name_length, self.column_limit_db_alias), expected = [
hint=("Use 'through' to create a separate model for " Error(
"M2M and then set column_name using 'db_column'."), 'Autogenerated column name too long for M2M field "%s". '
obj=ModelWithLongField, 'Maximum length is "%s" for database "%s".'
id='models.E019', % (m2m_long_name, self.max_column_name_length, self.column_limit_db_alias),
) hint=("Use 'through' to create a separate model for "
] "M2M and then set column_name using 'db_column'."),
obj=ModelWithLongField,
id='models.E019',
)
]
# Second error because the FK specified in the `through` model # Second error because the FK specified in the `through` model
# `m2msimple` has auto-genererated name longer than allowed. # `m2msimple` has auto-genererated name longer than allowed.