Re: [sqlalchemy] Mixed data type for a column

2015-09-18 Thread Mattias Lagergren
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

Re: [sqlalchemy] Mixed data type for a column

2015-09-18 Thread Mattias Lagergren
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

Re: [sqlalchemy] Mixed data type for a column

2015-09-17 Thread Mattias Lagergren
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

[sqlalchemy] Mixed data type for a column

2015-09-16 Thread Mattias Lagergren
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

Re: [sqlalchemy] Mixed data type for a column

2015-09-16 Thread Mike Bayer
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)