diff options
Diffstat (limited to 'tests/db_functions')
| -rw-r--r-- | tests/db_functions/test_cast.py | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/tests/db_functions/test_cast.py b/tests/db_functions/test_cast.py index 70de20e5eb..bd4541bf06 100644 --- a/tests/db_functions/test_cast.py +++ b/tests/db_functions/test_cast.py @@ -1,7 +1,7 @@ from django.db import models from django.db.models.expressions import Value from django.db.models.functions import Cast -from django.test import TestCase +from django.test import TestCase, ignore_warnings, skipUnlessDBFeature from .models import Author @@ -19,6 +19,13 @@ class CastTests(TestCase): numbers = Author.objects.annotate(cast_string=Cast('age', models.CharField(max_length=255)),) self.assertEqual(numbers.get().cast_string, '1') + # Silence "Truncated incorrect CHAR(1) value: 'Bob'". + @ignore_warnings(module='django.db.backends.mysql.base') + @skipUnlessDBFeature('supports_cast_with_precision') + def test_cast_to_char_field_with_max_length(self): + names = Author.objects.annotate(cast_string=Cast('name', models.CharField(max_length=1))) + self.assertEqual(names.get().cast_string, 'B') + def test_cast_to_integer(self): for field_class in ( models.IntegerField, |
