mirror of
https://github.com/django/django.git
synced 2025-07-19 19:25:26 +00:00
Fixed #24183 -- Fixed wrong comparisons in Substr
This commit is contained in:
parent
7f20041bca
commit
61c102d010
2 changed files with 14 additions and 2 deletions
|
@ -278,6 +278,18 @@ class FunctionTests(TestCase):
|
|||
with six.assertRaisesRegex(self, ValueError, "'pos' must be greater than 0"):
|
||||
Author.objects.annotate(raises=Substr('name', 0))
|
||||
|
||||
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', V(5), V(3)))
|
||||
self.assertQuerysetEqual(
|
||||
authors.order_by('name'), [
|
||||
' Sm',
|
||||
'da',
|
||||
],
|
||||
lambda a: a.name_part
|
||||
)
|
||||
|
||||
def test_nested_function_ordering(self):
|
||||
Author.objects.create(name='John Smith')
|
||||
Author.objects.create(name='Rhonda Simpson', alias='ronny')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue