Loading django/db/models/lookups.py +1 −1 Original line number Diff line number Diff line Loading @@ -204,7 +204,7 @@ class BuiltinLookup(Lookup): lhs_sql = connection.ops.field_cast_sql( db_type, field_internal_type) % lhs_sql lhs_sql = connection.ops.lookup_cast(self.lookup_name, field_internal_type) % lhs_sql return lhs_sql, params return lhs_sql, list(params) def as_sql(self, compiler, connection): lhs_sql, params = self.process_lhs(compiler, connection) Loading docs/releases/1.8.6.txt +2 −0 Original line number Diff line number Diff line Loading @@ -21,3 +21,5 @@ Bugfixes * Fixed incorrect queries when you have multiple ``ManyToManyField``\s on different models that have the same field name, point to the same model, and have their reverse relations disabled (:ticket:`25545`). * Allowed filtering over a ``RawSQL`` annotation (:ticket:`25506`). tests/expressions/tests.py +12 −0 Original line number Diff line number Diff line Loading @@ -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 Loading Loading
django/db/models/lookups.py +1 −1 Original line number Diff line number Diff line Loading @@ -204,7 +204,7 @@ class BuiltinLookup(Lookup): lhs_sql = connection.ops.field_cast_sql( db_type, field_internal_type) % lhs_sql lhs_sql = connection.ops.lookup_cast(self.lookup_name, field_internal_type) % lhs_sql return lhs_sql, params return lhs_sql, list(params) def as_sql(self, compiler, connection): lhs_sql, params = self.process_lhs(compiler, connection) Loading
docs/releases/1.8.6.txt +2 −0 Original line number Diff line number Diff line Loading @@ -21,3 +21,5 @@ Bugfixes * Fixed incorrect queries when you have multiple ``ManyToManyField``\s on different models that have the same field name, point to the same model, and have their reverse relations disabled (:ticket:`25545`). * Allowed filtering over a ``RawSQL`` annotation (:ticket:`25506`).
tests/expressions/tests.py +12 −0 Original line number Diff line number Diff line Loading @@ -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 Loading