summaryrefslogtreecommitdiff
path: root/tests/db_functions
diff options
context:
space:
mode:
authorDaniel Hones <danielhones@gmail.com>2018-01-22 23:43:16 -0500
committerTim Graham <timograham@gmail.com>2018-01-24 08:07:28 -0500
commit9d129b72cea9e9e3850f3f657136ba3bbf6f633f (patch)
tree660c2cb7689f20e5349d11f68e7e0e362725fb9c /tests/db_functions
parent2870879981d11619ca383ada1223d384fdc0ac51 (diff)
Fixed #29047 -- Corrected Substr test to use expressions.
Regression in e2d6e14662d780383e18066a3182155fb5b7747b.
Diffstat (limited to 'tests/db_functions')
-rw-r--r--tests/db_functions/tests.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/tests/db_functions/tests.py b/tests/db_functions/tests.py
index ddfb582a98..70d4d802cd 100644
--- a/tests/db_functions/tests.py
+++ b/tests/db_functions/tests.py
@@ -6,8 +6,8 @@ from django.db import connection
from django.db.models import CharField, TextField, Value as V
from django.db.models.expressions import RawSQL
from django.db.models.functions import (
- Coalesce, Concat, ConcatPair, Greatest, Least, Length, Lower, Now, Substr,
- Upper,
+ Coalesce, Concat, ConcatPair, Greatest, Least, Length, Lower, Now,
+ StrIndex, Substr, Upper,
)
from django.test import TestCase, skipIfDBFeature, skipUnlessDBFeature
from django.utils import timezone
@@ -510,11 +510,12 @@ class FunctionTests(TestCase):
def test_substr_with_expressions(self):
Author.objects.create(name='John Smith', alias='smithj')
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(
authors.order_by('name'), [
- ' Sm',
- 'da',
+ 'HN SM',
+ 'HONDA',
],
lambda a: a.name_part
)