Fixed #34480 -- Fixed crash of annotations with Chr().

This commit is contained in:
Jacob Walls 2023-04-10 16:30:08 -04:00 committed by Mariusz Felisiak
parent 3b4728310a
commit c3d7a71f83
2 changed files with 12 additions and 1 deletions

View file

@ -1,4 +1,4 @@
from django.db.models import IntegerField
from django.db.models import F, IntegerField
from django.db.models.functions import Chr, Left, Ord
from django.test import TestCase
from django.test.utils import register_lookup
@ -37,3 +37,13 @@ class ChrTests(TestCase):
authors.exclude(name_code_point__chr=Chr(ord("J"))),
[self.elena, self.rhonda],
)
def test_annotate(self):
authors = Author.objects.annotate(
first_initial=Left("name", 1),
initial_chr=Chr(ord("J")),
)
self.assertSequenceEqual(
authors.filter(first_initial=F("initial_chr")),
[self.john],
)