summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAntoine Catton <acatton@fusionbox.com>2015-10-05 14:13:14 -0600
committerTim Graham <timograham@gmail.com>2015-10-14 11:24:12 -0700
commit36e7d275ec1a65c9378ba29d4be005deb5703889 (patch)
tree8b8ef32f4497c6b249901300cdbbed97af0f158b /tests
parent38d6e1e2ada93e5d8c672ba18f1f8e3cd6c5ca76 (diff)
[1.9.x] Fixed #25506 -- Allowed filtering over a RawSQL annotation.
Co-Authored-By: Gavin Wahl <gwahl@fusionbox.com> Backport of b971c1cd78a0bf831c1c30080089c4a384d037a0 from master
Diffstat (limited to 'tests')
-rw-r--r--tests/expressions/tests.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/expressions/tests.py b/tests/expressions/tests.py
index 1af0b6e7a2..f68892782f 100644
--- a/tests/expressions/tests.py
+++ b/tests/expressions/tests.py
@@ -57,6 +57,18 @@ class BasicExpressionsTests(TestCase):
)
self.assertEqual(companies['result'], 2395)
+ def test_annotate_values_filter(self):
+ companies = Company.objects.annotate(
+ foo=RawSQL('%s', ['value']),
+ ).filter(foo='value').order_by('name')
+ self.assertQuerysetEqual(
+ companies, [
+ '<Company: Example Inc.>',
+ '<Company: Foobar Ltd.>',
+ '<Company: Test GmbH>',
+ ],
+ )
+
def test_filter_inter_attribute(self):
# We can filter on attribute relationships on same model obj, e.g.
# find companies where the number of employees is greater