diff options
| author | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2018-04-03 18:24:04 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-04-03 18:24:04 +0200 |
| commit | 6141c752fe7091d2197f5ac061300a9e0a36b09b (patch) | |
| tree | 30ca645d5c1b0e5d17d59c988332235d833d8a58 /tests | |
| parent | 4f7467b6905482a5d826c2815dcf8c6dd332340d (diff) | |
Fixed #29251 -- Added bytes to str conversion in LPad/RPad database functions on MySQL.
Thanks Tim Graham for the review.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/db_functions/test_pad.py | 14 |
1 files changed, 12 insertions, 2 deletions
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, + ) |
