I've been using the ORM exclusively for my project and I've run into a 
particular case that has me stumped:

I'm trying to find a way to generate SQL that essentially looks like this, 
using session.query() as a base:  (Running on PostgreSQL)

SELECT model.*, series.number
FROM model, generate_series(1,100) AS series(number)
WHERE some_where_clauses AND series.number some_condition

The closest solutions I've found all have one or more of the following 
problems:

   - They non-ORM methods (e.g. select() instead of query() and a lot of 
   text())
   - They end up wrapping generate_series in a subselect -- SELECT .... 
   FROM (SELECT generate_series(...)).  This is technically legal(*) 
   - They don't give me a way to properly alias both the "table" and its 
   columns (in the case of 
   session.query(...).select_from(sql.func.generate_series(...)))

Any ideas what I should be doing here?  FWIW, it seems like this similar 
situation could potentially crop up if using a RDBMS that supported 
parameterized views (Postgres doesn't, yet) -- though at least that 
situation would (probably) know what the output columns are from reflection.

-- Daniel

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to