mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Fixed #33435 -- Fixed invalid SQL generatered by Subquery.as_sql().
This commit is contained in:
committed by
Mariusz Felisiak
parent
b55ebe3241
commit
f37face331
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user