Re: [sqlalchemy] string_agg() with order by clause

2010-08-30 Thread David Gardner
On 08/27/2010 09:21 PM, Michael Bayer wrote: you coerce incoming arguments into expressions at the constructor level: from sqlalchemy.sql.expression import _literal_as_column class MyWhatever(ColumnElement): def __init__(self, expr, ...): self.expr = _literal_as_column(expr)

[sqlalchemy] string_agg() with order by clause

2010-08-27 Thread David Gardner
Recently Postgres added a new aggregate function called string_agg(). I have been able to use it like: Session.query(Asset, func.string_agg(some_col, ',')) This works, but according to the docs I should be able to do string_agg(some_col, ',' ORDER BY some_col) Is there a way to do this in

Re: [sqlalchemy] string_agg() with order by clause

2010-08-27 Thread David Gardner
I should have linked to the docs in question http://developer.postgresql.org/pgdocs/postgres/sql-expressions.html#SYNTAX-AGGREGATES On 08/27/2010 03:03 PM, David Gardner wrote: Recently Postgres added a new aggregate function called string_agg(). I have been able to use it like:

Re: [sqlalchemy] string_agg() with order by clause

2010-08-27 Thread Conor
On 08/27/2010 05:06 PM, David Gardner wrote: I should have linked to the docs in question http://developer.postgresql.org/pgdocs/postgres/sql-expressions.html#SYNTAX-AGGREGATES On 08/27/2010 03:03 PM, David Gardner wrote: Recently Postgres added a new aggregate function called string_agg().

Re: [sqlalchemy] string_agg() with order by clause

2010-08-27 Thread David Gardner
Fantastic! That works. Out of curiosity I noticed that the compile function expects to receive instances of Column. This isn't a big problem because I just reverted to doing table_var.c.my_col, but is there a simpler way to use MyClassName.Col? On 08/27/2010 04:02 PM, Conor wrote: On

Re: [sqlalchemy] string_agg() with order by clause

2010-08-27 Thread Michael Bayer
On Aug 27, 2010, at 8:56 PM, David Gardner wrote: Fantastic! That works. Out of curiosity I noticed that the compile function expects to receive instances of Column. This isn't a big problem because I just reverted to doing table_var.c.my_col, but is there a simpler way to use