Create the SQL for this query. Return the SQL string and list of parameters.
(self)
| 2005 | return f"{delete} WHERE {where}", tuple(params) |
| 2006 | |
| 2007 | def as_sql(self): |
| 2008 | """ |
| 2009 | Create the SQL for this query. Return the SQL string and list of |
| 2010 | parameters. |
| 2011 | """ |
| 2012 | if self.single_alias and ( |
| 2013 | self.connection.features.delete_can_self_reference_subquery |
| 2014 | or not self.contains_self_reference_subquery |
| 2015 | ): |
| 2016 | return self._as_sql(self.query) |
| 2017 | innerq = self.query.clone() |
| 2018 | innerq.__class__ = Query |
| 2019 | innerq.clear_select_clause() |
| 2020 | pk = self.query.model._meta.pk |
| 2021 | innerq.select = [pk.get_col(self.query.get_initial_alias())] |
| 2022 | outerq = Query(self.query.model) |
| 2023 | if not self.connection.features.update_can_self_select: |
| 2024 | # Force the materialization of the inner query to allow reference |
| 2025 | # to the target table on MySQL. |
| 2026 | sql, params = innerq.get_compiler(connection=self.connection).as_sql() |
| 2027 | innerq = RawSQL("SELECT * FROM (%s) subquery" % sql, params) |
| 2028 | outerq.add_filter("pk__in", innerq) |
| 2029 | return self._as_sql(outerq) |
| 2030 | |
| 2031 | |
| 2032 | class SQLUpdateCompiler(SQLCompiler): |
nothing calls this directly
no test coverage detected