From f37face331f21cb8af70fc4ec101ec7b6be1f63e Mon Sep 17 00:00:00 2001 From: My-Name-Is-Nabil Date: Sat, 15 Jan 2022 01:38:31 +0200 Subject: Fixed #33435 -- Fixed invalid SQL generatered by Subquery.as_sql(). --- tests/expressions/tests.py | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'tests') diff --git a/tests/expressions/tests.py b/tests/expressions/tests.py index 06c9ad597a..5cf9dd1ea5 100644 --- a/tests/expressions/tests.py +++ b/tests/expressions/tests.py @@ -537,6 +537,15 @@ class BasicExpressionsTests(TestCase): qs.query.annotations['small_company'], ) + def test_subquery_sql(self): + employees = Employee.objects.all() + employees_subquery = Subquery(employees) + self.assertIs(employees_subquery.query.subquery, True) + self.assertIs(employees.query.subquery, False) + compiler = employees_subquery.query.get_compiler(connection=connection) + sql, _ = employees_subquery.as_sql(compiler, connection) + self.assertIn('(SELECT ', sql) + def test_in_subquery(self): # This is a contrived test (and you really wouldn't write this query), # but it is a succinct way to test the __in=Subquery() construct. -- cgit v1.3