Represent a PostgreSQL aggregate order by expression. E.g.:: from sqlalchemy.dialects.postgresql import aggregate_order_by expr = func.array_agg(aggregate_order_by(table.c.a, table.c.b.desc())) stmt = select(expr) would represent the expression: .. sourcecode
| 45 | |
| 46 | |
| 47 | class aggregate_order_by(expression.ColumnElement[_T]): |
| 48 | """Represent a PostgreSQL aggregate order by expression. |
| 49 | |
| 50 | E.g.:: |
| 51 | |
| 52 | from sqlalchemy.dialects.postgresql import aggregate_order_by |
| 53 | |
| 54 | expr = func.array_agg(aggregate_order_by(table.c.a, table.c.b.desc())) |
| 55 | stmt = select(expr) |
| 56 | |
| 57 | would represent the expression: |
| 58 | |
| 59 | .. sourcecode:: sql |
| 60 | |
| 61 | SELECT array_agg(a ORDER BY b DESC) FROM table; |
| 62 | |
| 63 | .. legacy:: An improved dialect-agnostic form of this function is now |
| 64 | available in Core by calling the |
| 65 | :meth:`_functions.Function.aggregate_order_by` method on any function |
| 66 | defined by the backend as an aggregate function. |
| 67 | |
| 68 | .. seealso:: |
| 69 | |
| 70 | :func:`_sql.aggregate_order_by` - Core level function |
| 71 | |
| 72 | :class:`_functions.array_agg` |
| 73 | |
| 74 | """ |
| 75 | |
| 76 | __visit_name__ = "aggregate_order_by" |
| 77 | |
| 78 | stringify_dialect = "postgresql" |
| 79 | _traverse_internals: _TraverseInternalsType = [ |
| 80 | ("target", InternalTraversal.dp_clauseelement), |
| 81 | ("type", InternalTraversal.dp_type), |
| 82 | ("order_by", InternalTraversal.dp_clauseelement), |
| 83 | ] |
| 84 | |
| 85 | @overload |
| 86 | def __init__( |
| 87 | self, |
| 88 | target: ColumnElement[_T], |
| 89 | *order_by: _ColumnExpressionArgument[Any], |
| 90 | ): ... |
| 91 | |
| 92 | @overload |
| 93 | def __init__( |
| 94 | self, |
| 95 | target: _ColumnExpressionArgument[_T], |
| 96 | *order_by: _ColumnExpressionArgument[Any], |
| 97 | ): ... |
| 98 | |
| 99 | def __init__( |
| 100 | self, |
| 101 | target: _ColumnExpressionArgument[_T], |
| 102 | *order_by: _ColumnExpressionArgument[Any], |
| 103 | ): |
| 104 | self.target: ClauseElement = coercions.expect( |
no outgoing calls