Fixed #28371 -- Fixed Cast() with CharField if the max_length argument isn't provided.

Thanks Tim Graham for the review.
This commit is contained in:
Mariusz Felisiak 2017-07-27 19:36:47 +02:00 committed by GitHub
parent 14172cf442
commit b61d5b1991
8 changed files with 25 additions and 0 deletions

View file

@ -19,6 +19,10 @@ class CastTests(TestCase):
numbers = Author.objects.annotate(cast_string=Cast('age', models.CharField(max_length=255)),)
self.assertEqual(numbers.get().cast_string, '1')
def test_cast_to_char_field_without_max_length(self):
numbers = Author.objects.annotate(cast_string=Cast('age', models.CharField()))
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')