Ticket #29155: 29155-test.diff

File 29155-test.diff, 1.1 KB (added by Tim Graham, 6 years ago)
  • tests/db_functions/tests.py

    diff --git a/tests/db_functions/tests.py b/tests/db_functions/tests.py
    index 4331e02..eaf0401 100644
    a b from decimal import Decimal  
    33from unittest import skipIf, skipUnless
    44
    55from django.db import connection
    6 from django.db.models import CharField, TextField, Value as V
     6from django.db.models import CharField, F, TextField, Value as V
    77from django.db.models.expressions import RawSQL
    88from django.db.models.functions import (
    99    Coalesce, Concat, ConcatPair, Greatest, Least, Length, Lower, Now,
    class FunctionTests(TestCase):  
    519519            lambda a: a.name_part
    520520        )
    521521
     522    def test_substr_with_startswith(self):
     523        a = Author.objects.create(name='John Smith', alias='John')
     524        authors = Author.objects.filter(name__startswith=Substr(F('alias'), 1, 3))
     525        self.assertCountEqual(authors, [a])
     526
    522527    def test_nested_function_ordering(self):
    523528        Author.objects.create(name='John Smith')
    524529        Author.objects.create(name='Rhonda Simpson', alias='ronny')
Back to Top