Hi again Michael,
I'm still working with this problem but have changed it so that I'm no
longer trying to CAST in the database, since you made me aware about the
limitations of mixed types in traditional RDBMS.
What I want is a column, casted_value, on the model that gives me the
CASTed
Forgot the actual question; is there a better less complicated solution?
With hybrid_property expression I get into the problem that it doesn't load
up front: session.query(Variable_Value)
Thanks!
Mattias L
On Friday, September 18, 2015 at 12:25:41 PM UTC+2, Mattias Lagergren wrote:
>
> Hi
Hi Michael,
Thank you for your quick reply and clarifying both SqlAlchemy and the
SQL-side.
Also, the mixing of SQL-side CAST with a SQL column that is essentially
> just a string is not correct. On the SQL side, operations with this column
> all deal with the same type (string) so there's
Hi,
I have a table (variable_value) with a "value" column where I store a mix
of data (float, boolean, datetime) as strings. On a related table the type
is stored and now I'm trying to create a new calculated column
"casted_value" that casts the value column to the correct type in SQL (I'm
On 9/16/15 6:46 AM, Mattias Lagergren wrote:
The important part is the casting inside of the case expression:
|
dynamic_cast=sqlalchemy.sql.expression.case(
[
(
variable_register.c.type =='number',
sqlalchemy.cast(variable_value.c.value,types.Numeric)