Kaydet (Commit) 9d129b72 authored tarafından Daniel Hones's avatar Daniel Hones Kaydeden (comit) Tim Graham

Fixed #29047 -- Corrected Substr test to use expressions.

Regression in e2d6e146.
üst 28708799
...@@ -6,8 +6,8 @@ from django.db import connection ...@@ -6,8 +6,8 @@ from django.db import connection
from django.db.models import CharField, TextField, Value as V from django.db.models import CharField, TextField, Value as V
from django.db.models.expressions import RawSQL from django.db.models.expressions import RawSQL
from django.db.models.functions import ( from django.db.models.functions import (
Coalesce, Concat, ConcatPair, Greatest, Least, Length, Lower, Now, Substr, Coalesce, Concat, ConcatPair, Greatest, Least, Length, Lower, Now,
Upper, StrIndex, Substr, Upper,
) )
from django.test import TestCase, skipIfDBFeature, skipUnlessDBFeature from django.test import TestCase, skipIfDBFeature, skipUnlessDBFeature
from django.utils import timezone from django.utils import timezone
...@@ -510,11 +510,12 @@ class FunctionTests(TestCase): ...@@ -510,11 +510,12 @@ class FunctionTests(TestCase):
def test_substr_with_expressions(self): def test_substr_with_expressions(self):
Author.objects.create(name='John Smith', alias='smithj') Author.objects.create(name='John Smith', alias='smithj')
Author.objects.create(name='Rhonda') Author.objects.create(name='Rhonda')
authors = Author.objects.annotate(name_part=Substr('name', 5, 3)) substr = Substr(Upper('name'), StrIndex('name', V('h')), 5, output_field=CharField())
authors = Author.objects.annotate(name_part=substr)
self.assertQuerysetEqual( self.assertQuerysetEqual(
authors.order_by('name'), [ authors.order_by('name'), [
' Sm', 'HN SM',
'da', 'HONDA',
], ],
lambda a: a.name_part lambda a: a.name_part
) )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment