summaryrefslogtreecommitdiff
path: root/tests/db_functions
diff options
context:
space:
mode:
authorJosh Smeaton <josh.smeaton@gmail.com>2015-01-20 11:47:13 +1100
committerJosh Smeaton <josh.smeaton@gmail.com>2015-01-20 12:09:15 +1100
commit61c102d010ef480cebe576cc1576d1101975925c (patch)
treec25caa04f68e00aa21164e886ce39e6bc098dd3b /tests/db_functions
parent7f20041bca43ca33f0a9617793f2af7ab07c3fab (diff)
Fixed #24183 -- Fixed wrong comparisons in Substr
Diffstat (limited to 'tests/db_functions')
-rw-r--r--tests/db_functions/tests.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/db_functions/tests.py b/tests/db_functions/tests.py
index 00a5e258de..97d32d86e7 100644
--- a/tests/db_functions/tests.py
+++ b/tests/db_functions/tests.py
@@ -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')