(self, compiler, connection, template=None, **extra_context)
| 1942 | return [self.expression] |
| 1943 | |
| 1944 | def as_sql(self, compiler, connection, template=None, **extra_context): |
| 1945 | if isinstance(self.expression, ColPairs): |
| 1946 | sql_parts = [] |
| 1947 | params = [] |
| 1948 | for col in self.expression.get_cols(): |
| 1949 | copy = self.copy() |
| 1950 | copy.set_source_expressions([col]) |
| 1951 | sql, col_params = compiler.compile(copy) |
| 1952 | sql_parts.append(sql) |
| 1953 | params.extend(col_params) |
| 1954 | return ", ".join(sql_parts), params |
| 1955 | template = template or self.template |
| 1956 | if connection.features.supports_order_by_nulls_modifier: |
| 1957 | if self.nulls_last: |
| 1958 | template = "%s NULLS LAST" % template |
| 1959 | elif self.nulls_first: |
| 1960 | template = "%s NULLS FIRST" % template |
| 1961 | else: |
| 1962 | if self.nulls_last and not ( |
| 1963 | self.descending and connection.features.order_by_nulls_first |
| 1964 | ): |
| 1965 | template = "%%(expression)s IS NULL, %s" % template |
| 1966 | elif self.nulls_first and not ( |
| 1967 | not self.descending and connection.features.order_by_nulls_first |
| 1968 | ): |
| 1969 | template = "%%(expression)s IS NOT NULL, %s" % template |
| 1970 | connection.ops.check_expression_support(self) |
| 1971 | expression_sql, params = compiler.compile(self.expression) |
| 1972 | placeholders = { |
| 1973 | "expression": expression_sql, |
| 1974 | "ordering": "DESC" if self.descending else "ASC", |
| 1975 | **extra_context, |
| 1976 | } |
| 1977 | params *= template.count("%(expression)s") |
| 1978 | return (template % placeholders).rstrip(), params |
| 1979 | |
| 1980 | def as_oracle(self, compiler, connection): |
| 1981 | # Oracle < 23c doesn't allow ORDER BY EXISTS() or filters unless it's |
no test coverage detected