its a little awkward but if you use bindparam() in the inner select, 
query.params() can access those parameters just fine, you'd just need to use it 
in all cases.

there's some related example of doing this with a relationship at 
http://www.sqlalchemy.org/trac/wiki/UsageRecipes/GlobalFilter .


On Oct 13, 2011, at 6:39 PM, Burak Arslan wrote:

> hi,
> 
> is there a way to pass a parameter to a subquery inside a select mapped
> to a class? the generated query looks like this:
> 
> select * from (
>    select distinct on (some_table.id) some_table.id, ... from
> some_table where some_condition
> ) as v join ...
> 
> the outer select is mapped to a class, but when i try to query on that
> class, the conditions are naturally applied to the outer query. because
> of distinct in the subquery, i get random results. i need to put
> conditions on the inner query. (and yes, I do need that distinct in
> there. i can't put it to the outer query because that messes with order
> by. i can't use group by because not all columns respond to aggregates.)
> 
> should I just drop the orm for this specific case?
> 
> thanks,
> burak
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "sqlalchemy" group.
> To post to this group, send email to sqlalchemy@googlegroups.com.
> To unsubscribe from this group, send email to 
> sqlalchemy+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/sqlalchemy?hl=en.
> 

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to