diff options
| author | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2017-05-23 17:02:40 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-05-23 17:02:40 +0200 |
| commit | 538bf43458a147b7edeb7118c9f325c3f59ff6fb (patch) | |
| tree | a1724f358e8d8829c0c68b1e8bba6882d108fc53 /tests/invalid_models_tests/test_ordinary_fields.py | |
| parent | b3eb6eaf1a197ff155faf333871da032c77ba855 (diff) | |
Fixed #27859 -- Ignored db_index for TextField/BinaryField on Oracle and MySQL.
Thanks Zubair Alam for the initial patch and Tim Graham for the review.
Diffstat (limited to 'tests/invalid_models_tests/test_ordinary_fields.py')
| -rw-r--r-- | tests/invalid_models_tests/test_ordinary_fields.py | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/tests/invalid_models_tests/test_ordinary_fields.py b/tests/invalid_models_tests/test_ordinary_fields.py index 90f4b31902..cad375aae5 100644 --- a/tests/invalid_models_tests/test_ordinary_fields.py +++ b/tests/invalid_models_tests/test_ordinary_fields.py @@ -2,7 +2,7 @@ import unittest from django.core.checks import Error, Warning as DjangoWarning from django.db import connection, models -from django.test import SimpleTestCase, TestCase +from django.test import SimpleTestCase, TestCase, skipIfDBFeature from django.test.utils import isolate_apps, override_settings from django.utils.timezone import now @@ -646,3 +646,26 @@ class TimeFieldTests(TestCase): @override_settings(USE_TZ=True) def test_fix_default_value_tz(self): self.test_fix_default_value() + + +@isolate_apps('invalid_models_tests') +class TextFieldTests(TestCase): + + @skipIfDBFeature('supports_index_on_text_field') + def test_max_length_warning(self): + class Model(models.Model): + value = models.TextField(db_index=True) + field = Model._meta.get_field('value') + field_type = field.db_type(connection) + self.assertEqual(field.check(), [ + DjangoWarning( + '%s does not support a database index on %s columns.' + % (connection.display_name, field_type), + hint=( + "An index won't be created. Silence this warning if you " + "don't care about it." + ), + obj=field, + id='fields.W162', + ) + ]) |
