From 6141c752fe7091d2197f5ac061300a9e0a36b09b Mon Sep 17 00:00:00 2001 From: Mariusz Felisiak Date: Tue, 3 Apr 2018 18:24:04 +0200 Subject: Fixed #29251 -- Added bytes to str conversion in LPad/RPad database functions on MySQL. Thanks Tim Graham for the review. --- tests/db_functions/test_pad.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/db_functions/test_pad.py b/tests/db_functions/test_pad.py index d873345fc4..1c2caf06b5 100644 --- a/tests/db_functions/test_pad.py +++ b/tests/db_functions/test_pad.py @@ -1,5 +1,5 @@ -from django.db.models import Value -from django.db.models.functions import LPad, RPad +from django.db.models import CharField, Value +from django.db.models.functions import Length, LPad, RPad from django.test import TestCase from .models import Author @@ -32,3 +32,13 @@ class PadTests(TestCase): with self.subTest(function=function): with self.assertRaisesMessage(ValueError, "'length' must be greater or equal to 0."): function('name', -1) + + def test_combined_with_length(self): + Author.objects.create(name='Rhonda', alias='john_smith') + Author.objects.create(name='♥♣♠', alias='bytes') + authors = Author.objects.annotate(filled=LPad('name', Length('alias'), output_field=CharField())) + self.assertQuerysetEqual( + authors.order_by('alias'), + [' ♥♣♠', ' Rhonda'], + lambda a: a.filled, + ) -- cgit v1.3