(self, style)
| 1146 | |
| 1147 | @testing.variation("style", ["none", "inline", "within_group"]) |
| 1148 | def test_aggregate_order_by_one(self, style): |
| 1149 | table = Table( |
| 1150 | "table1", MetaData(), Column("a", Integer), Column("b", Integer) |
| 1151 | ) |
| 1152 | expr = func.array_agg(table.c.a).aggregate_order_by(table.c.b.desc()) |
| 1153 | stmt = select(expr) |
| 1154 | |
| 1155 | if style.none: |
| 1156 | dialect = default.DefaultDialect() |
| 1157 | dialect.aggregate_order_by_style = AggregateOrderByStyle.NONE |
| 1158 | with expect_raises_message( |
| 1159 | exc.CompileError, |
| 1160 | "this dialect does not support ORDER BY " |
| 1161 | "within an aggregate function", |
| 1162 | ): |
| 1163 | stmt.compile(dialect=dialect) |
| 1164 | elif style.within_group: |
| 1165 | dialect = default.DefaultDialect() |
| 1166 | dialect.aggregate_order_by_style = ( |
| 1167 | AggregateOrderByStyle.WITHIN_GROUP |
| 1168 | ) |
| 1169 | self.assert_compile( |
| 1170 | stmt, |
| 1171 | "SELECT array_agg(table1.a) " |
| 1172 | "WITHIN GROUP (ORDER BY table1.b DESC) " |
| 1173 | "AS array_agg_1 FROM table1", |
| 1174 | dialect=dialect, |
| 1175 | ) |
| 1176 | else: |
| 1177 | self.assert_compile( |
| 1178 | stmt, |
| 1179 | "SELECT array_agg(table1.a ORDER BY table1.b DESC) " |
| 1180 | "AS array_agg_1 FROM table1", |
| 1181 | ) |
| 1182 | |
| 1183 | @testing.variation("style", ["inline", "within_group"]) |
| 1184 | def test_aggregate_order_by_two(self, style): |
nothing calls this directly
no test coverage detected