Return a quoted list of fields to use in DISTINCT ON part of the query. This method can alter the tables in the query, and thus it must be called before get_from_clause().
(self)
| 1032 | return result |
| 1033 | |
| 1034 | def get_distinct(self): |
| 1035 | """ |
| 1036 | Return a quoted list of fields to use in DISTINCT ON part of the query. |
| 1037 | |
| 1038 | This method can alter the tables in the query, and thus it must be |
| 1039 | called before get_from_clause(). |
| 1040 | """ |
| 1041 | result = [] |
| 1042 | params = [] |
| 1043 | opts = self.query.get_meta() |
| 1044 | |
| 1045 | for name in self.query.distinct_fields: |
| 1046 | parts = name.split(LOOKUP_SEP) |
| 1047 | _, targets, alias, joins, path, _, transform_function = self._setup_joins( |
| 1048 | parts, opts, None |
| 1049 | ) |
| 1050 | targets, alias, _ = self.query.trim_joins(targets, joins, path) |
| 1051 | for target in targets: |
| 1052 | if name in self.query.annotation_select: |
| 1053 | result.append(self.connection.ops.quote_name(name)) |
| 1054 | else: |
| 1055 | r, p = self.compile(transform_function(target, alias)) |
| 1056 | result.append(r) |
| 1057 | params.append(p) |
| 1058 | return result, params |
| 1059 | |
| 1060 | def find_ordering_name( |
| 1061 | self, name, opts, alias=None, default_order="ASC", already_seen=None |
no test coverage detected