diff --git a/django/db/models/sql/compiler.py b/django/db/models/sql/compiler.py index 51c3d6e661..e7ccba6151 100644 --- a/django/db/models/sql/compiler.py +++ b/django/db/models/sql/compiler.py @@ -482,10 +482,7 @@ class SQLCompiler(object): not self.query.distinct_fields and not self.query.select_for_update): obj.clear_ordering(True) - nested_sql = obj.get_compiler(connection=self.connection).as_sql(subquery=True) - if nested_sql == ('', ()): - raise EmptyResultSet - return nested_sql + return obj.get_compiler(connection=self.connection).as_sql(subquery=True) def get_default_columns(self, start_alias=None, opts=None, from_parent=None): """ @@ -1221,11 +1218,6 @@ class SQLAggregateCompiler(SQLCompiler): Creates the SQL for this query. Returns the SQL string and list of parameters. """ - # Empty SQL for the inner query is a marker that the inner query - # isn't going to produce any results. This can happen when doing - # LIMIT 0 queries (generated by qs[:0]) for example. - if not self.query.subquery: - raise EmptyResultSet sql, params = [], [] for annotation in self.query.annotation_select.values(): ann_sql, ann_params = self.compile(annotation, select_format=True)