diff options
Diffstat (limited to 'tests/expressions/tests.py')
| -rw-r--r-- | tests/expressions/tests.py | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/tests/expressions/tests.py b/tests/expressions/tests.py index 99f41024f8..320271b1dc 100644 --- a/tests/expressions/tests.py +++ b/tests/expressions/tests.py @@ -3,7 +3,7 @@ from __future__ import unicode_literals from django.core.exceptions import FieldError from django.db.models import F from django.db import transaction -from django.test import TestCase +from django.test import TestCase, skipIfDBFeature from django.utils import six from .models import Company, Employee @@ -224,6 +224,25 @@ class ExpressionsTests(TestCase): acme.num_employees = F("num_employees") + 16 self.assertRaises(TypeError, acme.save) + def test_ticket_11722_iexact_lookup(self): + Employee.objects.create(firstname="John", lastname="Doe") + Employee.objects.create(firstname="Test", lastname="test") + + queryset = Employee.objects.filter(firstname__iexact=F('lastname')) + self.assertQuerysetEqual(queryset, ["<Employee: Test test>"]) + + @skipIfDBFeature('has_case_insensitive_like') + def test_ticket_16731_startswith_lookup(self): + Employee.objects.create(firstname="John", lastname="Doe") + e2 = Employee.objects.create(firstname="Jack", lastname="Jackson") + e3 = Employee.objects.create(firstname="Jack", lastname="jackson") + self.assertQuerysetEqual( + Employee.objects.filter(lastname__startswith=F('firstname')), + [e2], lambda x: x) + self.assertQuerysetEqual( + Employee.objects.filter(lastname__istartswith=F('firstname')).order_by('pk'), + [e2, e3], lambda x: x) + def test_ticket_18375_join_reuse(self): # Test that reverse multijoin F() references and the lookup target # the same join. Pre #18375 the F() join was generated first, and the |
