mirror of
https://github.com/django/django.git
synced 2025-10-31 09:41:08 +00:00
[1.9.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
38d6e1e2ad
commit
36e7d275ec
@@ -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