MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_aggregate_order_by_two

Method test_aggregate_order_by_two

test/sql/test_functions.py:1184–1210  ·  view source on GitHub ↗
(self, style)

Source from the content-addressed store, hash-verified

1182
1183 @testing.variation("style", ["inline", "within_group"])
1184 def test_aggregate_order_by_two(self, style):
1185 table = Table(
1186 "table1", MetaData(), Column("a", Integer), Column("b", Integer)
1187 )
1188 expr = func.string_agg(
1189 table.c.a, literal_column("','")
1190 ).aggregate_order_by(table.c.a)
1191 stmt = select(expr)
1192
1193 if style.within_group:
1194 dialect = default.DefaultDialect()
1195 dialect.aggregate_order_by_style = (
1196 AggregateOrderByStyle.WITHIN_GROUP
1197 )
1198 self.assert_compile(
1199 stmt,
1200 "SELECT string_agg(table1.a, ',') "
1201 "WITHIN GROUP (ORDER BY table1.a) "
1202 "AS string_agg_1 FROM table1",
1203 dialect=dialect,
1204 )
1205 else:
1206 self.assert_compile(
1207 stmt,
1208 "SELECT string_agg(table1.a, ',' ORDER BY table1.a) "
1209 "AS string_agg_1 FROM table1",
1210 )
1211
1212 def test_aggregate_order_by_multi_col(self):
1213 table = Table(

Callers

nothing calls this directly

Calls 7

TableClass · 0.90
MetaDataClass · 0.90
ColumnClass · 0.90
literal_columnFunction · 0.90
selectFunction · 0.90
assert_compileMethod · 0.80
aggregate_order_byMethod · 0.45

Tested by

no test coverage detected