From b61d5b1991e2ca2c3450ccc334224f3d51da39dc Mon Sep 17 00:00:00 2001 From: Mariusz Felisiak Date: Thu, 27 Jul 2017 19:36:47 +0200 Subject: Fixed #28371 -- Fixed Cast() with CharField if the max_length argument isn't provided. Thanks Tim Graham for the review. --- tests/db_functions/test_cast.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'tests') diff --git a/tests/db_functions/test_cast.py b/tests/db_functions/test_cast.py index bd4541bf06..e266a13db1 100644 --- a/tests/db_functions/test_cast.py +++ b/tests/db_functions/test_cast.py @@ -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') -- cgit v1.3