summaryrefslogtreecommitdiff
path: root/tests/db_functions
diff options
context:
space:
mode:
authorJacob Walls <jwalls@element84.com>2023-04-10 16:30:08 -0400
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2023-04-11 05:56:47 +0200
commitc3d7a71f836f7cfe8fa90dd9ae95b37b660d5aae (patch)
treee08196e7d6a875817129c37fbd9cdeab86a82640 /tests/db_functions
parent3b4728310a7a64f8fcc548163b0aa5f98a5c78f5 (diff)
downloaddjango-c3d7a71f836f7cfe8fa90dd9ae95b37b660d5aae.tar.gz
Fixed #34480 -- Fixed crash of annotations with Chr().
Diffstat (limited to 'tests/db_functions')
-rw-r--r--tests/db_functions/text/test_chr.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/tests/db_functions/text/test_chr.py b/tests/db_functions/text/test_chr.py
index 7a55994096..fe1aea3f2c 100644
--- a/tests/db_functions/text/test_chr.py
+++ b/tests/db_functions/text/test_chr.py
@@ -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],
+ )