On Apr 23, 2:38 pm, Michael Bayer <[EMAIL PROTECTED]> wrote:
> On Apr 23, 2008, at 9:24 AM, Adrian wrote:
>
>
>
> > I should have mentioned that - cutoff is simply a float, e.g.
>
> > query = query.where(query.c.brayCurtis >= 0.8)
>
> > that's why I think there is a trivial solution. If I do the above, the
> > whole query will be added as a subquery and the where and order by
> > clauses duplicated. It works fine for the order_by statement though.
>
> If you want to force the label substitution, you can do it like this:
>
> where(literal_column('mylabelname') >= 0.8)
>
> or instead of pulling the label off the select itself, use the
> original label construct, which is not the same as stmt.c.labelname -
> this will repeat the expression, which is what many DBs will require,
> but because its not attached to a selectable (unlike
> stmt.c.labelname), will not pollute the FROM clause of the select
> (select() pulls FROM clauses from everything in the columns and where
> clauses):
>
> col = abs(foo - bar).sum() / float(...).label('somelabel')
>
> s = select([..., col, ...]).where(col > 0.8)

That's exactly what I was looking for, thanks!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to