diff options
| author | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2017-07-17 21:12:27 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-07-17 21:12:27 +0200 |
| commit | 776cee974933677730aef177eb5b5bdec3749c80 (patch) | |
| tree | e6435cf6aeabe6b436a87ab8fb1ef702608e8a74 /tests | |
| parent | feeafdad02e2874e2e2f879a825d3527f6b193ad (diff) | |
Fixed #28391 -- Fixed Cast() with CharField and max_length on MySQL.
Thanks Tim Graham for the review.
Diffstat (limited to 'tests')
| -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, |
