summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Manfre <mmanfre@gmail.com>2015-07-02 22:09:51 -0400
committerMichael Manfre <mmanfre@gmail.com>2015-07-02 22:09:51 -0400
commita15aa7ad4a84955444e9836003832fe62f54b8af (patch)
tree2be8a7626ff745d863a7049d306851bb88f44396
parenta570701e02e0bc09d977c8ae0b6ee987a1190039 (diff)
downloaddjango-ticket-25055.tar.gz
Fixed #25055 -- Made m2m long name testing friendlier for 3rd party databases.ticket-25055
-rw-r--r--tests/invalid_models_tests/test_models.py26
1 files changed, 15 insertions, 11 deletions
diff --git a/tests/invalid_models_tests/test_models.py b/tests/invalid_models_tests/test_models.py
index a2d9f36557..109cc5c285 100644
--- a/tests/invalid_models_tests/test_models.py
+++ b/tests/invalid_models_tests/test_models.py
@@ -328,17 +328,21 @@ class FieldNamesTests(IsolatedModelsTestCase):
# First error because of M2M field set on the model with long name.
m2m_long_name = "verylongmodelnamezzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz_id"
- expected = [
- Error(
- 'Autogenerated column name too long for M2M field "%s". '
- 'Maximum length is "%s" for database "%s".'
- % (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',
- )
- ]
+ if self.max_column_name_length > len(m2m_long_name):
+ # Some databases support names longer than the model name + '_id'
+ expected = []
+ else:
+ expected = [
+ Error(
+ 'Autogenerated column name too long for M2M field "%s". '
+ 'Maximum length is "%s" for database "%s".'
+ % (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
# `m2msimple` has auto-genererated name longer than allowed.