mirror of
https://github.com/django/django.git
synced 2025-10-24 14:16:09 +00:00
Refs #30446 -- Defined default output_field of text database functions.
This prevented the default behavior of BaseExpression._resolve_output_field from error'ing out when such functions accepted both expressions from mixed types (e.g. SubStr(CharField, IntegerField, IntegerField)).
This commit is contained in:
committed by
Mariusz Felisiak
parent
0d6d4e78b1
commit
ea3beb4f5a
@@ -1,4 +1,4 @@
|
||||
from django.db.models import CharField, Value as V
|
||||
from django.db.models import Value as V
|
||||
from django.db.models.functions import Lower, StrIndex, Substr, Upper
|
||||
from django.test import TestCase
|
||||
|
||||
@@ -45,7 +45,7 @@ class SubstrTests(TestCase):
|
||||
def test_expressions(self):
|
||||
Author.objects.create(name='John Smith', alias='smithj')
|
||||
Author.objects.create(name='Rhonda')
|
||||
substr = Substr(Upper('name'), StrIndex('name', V('h')), 5, output_field=CharField())
|
||||
substr = Substr(Upper('name'), StrIndex('name', V('h')), 5)
|
||||
authors = Author.objects.annotate(name_part=substr)
|
||||
self.assertQuerysetEqual(
|
||||
authors.order_by('name'), ['HN SM', 'HONDA'],
|
||||
|
||||
Reference in New Issue
Block a user