Michael Bayer wrote:

ok well how should it look ?  do you want to take a crack at it....?

I think just using cast(column_clause, type) would work in most/all places, i.e. single columns as well as calculated values.

I'll have a go at it shortly, but have a related question - is it possible to label calculated columns? i.e. to end up with

  SELECT date, (unit_price * qty) as total_price WHERE total_price > 1000;

as I think being able to cast the resulting value would be useful as well.

  SELECT date, (unit_price * qty) as total_price,
         round(CAST(total_price AS  numeric), 1) as rounded_total
  WHERE rounded_total BETWEEN 100.1 AND 100.5

(excuse the very contrived examples).

I've tried using various combinations of

  label('total_price', tbl.c.unit_price * tbl.c.qty)

and

  select.append_where(total_price > 1000)

but all of them fall over when using the label in a where clause (noting that the real code is using a more complicated self join to calculate the difference between the same column in two different rows).

Hints?

Robert




-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Sqlalchemy-users mailing list
Sqlalchemy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users

Reply via email to