mirror of
https://github.com/django/django.git
synced 2025-10-29 16:46:11 +00:00
[1.8.x] Fixed #25506 -- Allowed filtering over a RawSQL annotation.
Co-Authored-By: Gavin Wahl <gwahl@fusionbox.com>
Backport of b971c1cd78 from master
This commit is contained in:
committed by
Tim Graham
parent
4171d208f4
commit
ee6785ebea
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user