summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorSimon Charette <charette.s@gmail.com>2020-06-16 10:01:34 +0200
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2020-06-16 10:08:02 +0200
commitea3beb4f5a61870c87ba028369de4d2c2f316ad0 (patch)
tree6e3315aa9757a503698860d0f277254f26621c7c /django
parent0d6d4e78b17d7500e1a503fd2b02fdcf822d9d3c (diff)
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)).
Diffstat (limited to 'django')
-rw-r--r--django/db/models/functions/text.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/django/db/models/functions/text.py b/django/db/models/functions/text.py
index 9f3c0a9830..7289d5fb97 100644
--- a/django/db/models/functions/text.py
+++ b/django/db/models/functions/text.py
@@ -1,6 +1,6 @@
from django.db import NotSupportedError
from django.db.models.expressions import Func, Value
-from django.db.models.fields import IntegerField
+from django.db.models.fields import CharField, IntegerField
from django.db.models.functions import Coalesce
from django.db.models.lookups import Transform
@@ -135,6 +135,7 @@ class Concat(Func):
class Left(Func):
function = 'LEFT'
arity = 2
+ output_field = CharField()
def __init__(self, expression, length, **extra):
"""
@@ -173,6 +174,7 @@ class Lower(Transform):
class LPad(BytesToCharFieldConversionMixin, Func):
function = 'LPAD'
+ output_field = CharField()
def __init__(self, expression, length, fill_text=Value(' '), **extra):
if not hasattr(length, 'resolve_expression') and length is not None and length < 0:
@@ -204,6 +206,7 @@ class Ord(Transform):
class Repeat(BytesToCharFieldConversionMixin, Func):
function = 'REPEAT'
+ output_field = CharField()
def __init__(self, expression, number, **extra):
if not hasattr(number, 'resolve_expression') and number is not None and number < 0:
@@ -303,6 +306,7 @@ class StrIndex(Func):
class Substr(Func):
function = 'SUBSTRING'
+ output_field = CharField()
def __init__(self, expression, pos, length=None, **extra):
"""