Return a list of strings that are joined together to go after the "FROM" part of the query, as well as a list any extra parameters that need to be included. Subclasses, can override this to create a from-clause via a "select". This should only be called afte
(self)
| 1138 | return field, targets, alias, joins, path, opts, transform_function |
| 1139 | |
| 1140 | def get_from_clause(self): |
| 1141 | """ |
| 1142 | Return a list of strings that are joined together to go after the |
| 1143 | "FROM" part of the query, as well as a list any extra parameters that |
| 1144 | need to be included. Subclasses, can override this to create a |
| 1145 | from-clause via a "select". |
| 1146 | |
| 1147 | This should only be called after any SQL construction methods that |
| 1148 | might change the tables that are needed. This means the select columns, |
| 1149 | ordering, and distinct must be done first. |
| 1150 | """ |
| 1151 | result = [] |
| 1152 | params = [] |
| 1153 | # Copy alias_map to a tuple in case Join.as_sql() subclasses (objects |
| 1154 | # in alias_map) alter compiler.query.alias_map. That would otherwise |
| 1155 | # raise "RuntimeError: dictionary changed size during iteration". |
| 1156 | for alias, from_clause in tuple(self.query.alias_map.items()): |
| 1157 | if not self.query.alias_refcount[alias]: |
| 1158 | continue |
| 1159 | clause_sql, clause_params = self.compile(from_clause) |
| 1160 | result.append(clause_sql) |
| 1161 | params.extend(clause_params) |
| 1162 | for t in self.query.extra_tables: |
| 1163 | alias, _ = self.query.table_alias(t) |
| 1164 | # Only add the alias if it's not already present (the table_alias() |
| 1165 | # call increments the refcount, so an alias refcount of one means |
| 1166 | # this is the only reference). |
| 1167 | if ( |
| 1168 | alias not in self.query.alias_map |
| 1169 | or self.query.alias_refcount[alias] == 1 |
| 1170 | ): |
| 1171 | result.append(", %s" % self.quote_name(alias)) |
| 1172 | return result, params |
| 1173 | |
| 1174 | def get_related_selections( |
| 1175 | self, |
no test coverage detected