1
0
mirror of https://github.com/django/django.git synced 2025-10-23 21:59:11 +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:
Simon Charette
2020-06-16 10:01:34 +02:00
committed by Mariusz Felisiak
parent 0d6d4e78b1
commit ea3beb4f5a
6 changed files with 16 additions and 12 deletions

View File

@@ -1,5 +1,5 @@
from django.db import connection
from django.db.models import CharField, Value
from django.db.models import Value
from django.db.models.functions import Length, LPad, RPad
from django.test import TestCase
@@ -42,7 +42,7 @@ class PadTests(TestCase):
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()))
authors = Author.objects.annotate(filled=LPad('name', Length('alias')))
self.assertQuerysetEqual(
authors.order_by('alias'),
[' ♥♣♠', ' Rhonda'],