(self, compiler, connection, template=None)
| 2062 | self.source_expression, self.partition_by, self.order_by, self.frame = exprs |
| 2063 | |
| 2064 | def as_sql(self, compiler, connection, template=None): |
| 2065 | connection.ops.check_expression_support(self) |
| 2066 | if not connection.features.supports_over_clause: |
| 2067 | raise NotSupportedError("This backend does not support window expressions.") |
| 2068 | expr_sql, params = compiler.compile(self.source_expression) |
| 2069 | window_sql, window_params = [], () |
| 2070 | |
| 2071 | if self.partition_by is not None: |
| 2072 | sql_expr, sql_params = self.partition_by.as_sql( |
| 2073 | compiler=compiler, |
| 2074 | connection=connection, |
| 2075 | template="PARTITION BY %(expressions)s", |
| 2076 | ) |
| 2077 | window_sql.append(sql_expr) |
| 2078 | window_params += tuple(sql_params) |
| 2079 | |
| 2080 | if self.order_by is not None: |
| 2081 | order_sql, order_params = compiler.compile(self.order_by) |
| 2082 | window_sql.append(order_sql) |
| 2083 | window_params += tuple(order_params) |
| 2084 | |
| 2085 | if self.frame: |
| 2086 | frame_sql, frame_params = compiler.compile(self.frame) |
| 2087 | window_sql.append(frame_sql) |
| 2088 | window_params += tuple(frame_params) |
| 2089 | |
| 2090 | template = template or self.template |
| 2091 | |
| 2092 | return ( |
| 2093 | template % {"expression": expr_sql, "window": " ".join(window_sql).strip()}, |
| 2094 | (*params, *window_params), |
| 2095 | ) |
| 2096 | |
| 2097 | def as_sqlite(self, compiler, connection): |
| 2098 | if isinstance(self.output_field, fields.DecimalField): |
no test coverage detected