[sqlalchemy] Re: Columns division: cast() doen't seem to work. Or how to use it ?

2008-07-02 Thread Dominique
Hello Mike, Thank you very much for answering. I have to admit that I don't understand. session.query(Mytable).add_column(cast(Mytable.colB,Float) / cast(Mytable.colC,Float)).all() gives bad results while session.execute(SELECT * , CAST(Mytable.colB AS FLOAT) / CAST(Mytable.colC AS FLOAT)AS

[sqlalchemy] Re: Columns division: cast() doen't seem to work. Or how to use it ?

2008-07-02 Thread Michael Bayer
On Jul 2, 2008, at 12:38 PM, Dominique wrote: Hello Mike, Thank you very much for answering. I have to admit that I don't understand. session.query(Mytable).add_column(cast(Mytable.colB,Float) / cast(Mytable.colC,Float)).all() gives bad results while session.execute(SELECT * ,

[sqlalchemy] Re: Columns division: cast() doen't seem to work. Or how to use it ?

2008-07-02 Thread Dominique
Mike, I just had a quick look. See further in a moment. Thank you very much for your time, your work and your help. I really appreciate Dominique --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group.

[sqlalchemy] Re: Columns division: cast() doen't seem to work. Or how to use it ?

2008-07-01 Thread Dominique
Hi, Another way to ask the same question: How can I force SA to take floats into account rather than Numeric ? Even when columns are declared (in classes or through cast() ) as floats, SA seems to systematically convert them into Numeric, leading to the previous question... I tried making my

[sqlalchemy] Re: Columns division: cast() doen't seem to work. Or how to use it ?

2008-07-01 Thread Michael Bayer
the example program you posted is against SQLite. SQLite doesnt have floats per se, it only has REAL, and a type affinity called NUMERIC. See http://www.sqlite.org/datatype3.html .So the sqlite dialect in SA renders NUMERIC for the Float type. If you run it on postgres, you get: