[sqlalchemy] Re: column_property with load_only and inheritance

2015-12-21 Thread Mattias Lagergren
d ultimately led me to the solution. Since __declare_last__ runs for all the subclasses as well I ended up with the link attribute on both Context and the subclasses. Changing this to limit it only on Context solved the issue for me. Thanks! Mattias L On Monday, November 2, 2015 at 3:16:07 PM UTC+1

[sqlalchemy] Re: column_property with load_only and inheritance

2015-11-05 Thread Mattias Lagergren
, November 3, 2015 at 3:32:02 PM UTC+1, Mattias Lagergren wrote: > > Hi Michael, > > I've been putting together a self-contained example. If you save it to a > file test_model you should be able to run it: > > > import sqlalchemy > import sqlalchemy.orm > import

[sqlalchemy] Re: column_property with load_only and inheritance

2015-11-03 Thread Mattias Lagergren
tr. Best regards, Mattias L On Monday, November 2, 2015 at 3:16:07 PM UTC+1, Mattias Lagergren wrote: > > Hi, > > I'm trying to use load_only and joinedload on a relationship > model.Asset.parent. The parent relation is polymorphic and can be either > Task or Projec

[sqlalchemy] column_property with load_only and inheritance

2015-11-02 Thread Mattias Lagergren
Hi, I'm trying to use load_only and joinedload on a relationship model.Asset.parent. The parent relation is polymorphic and can be either Task or Project with the common Base class called Context. import sqlalchemy.orm import sqlalchemy.inspection entity =

Re: [sqlalchemy] Mixed data type for a column

2015-09-18 Thread Mattias Lagergren
oolean or other values: print session.query(model.Variable_Value).filter(model.Variable_Value.casted_value > 5).all() On Wednesday, September 16, 2015 at 5:00:02 PM UTC+2, Michael Bayer wrote: > > > > On 9/16/15 6:46 AM, Mattias Lagergren wrote: > > > The import

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: > &

[sqlalchemy] Re: Mixed data type for a column

2015-09-18 Thread Mattias Lagergren
Hi Jonathan, Yes, but as I mentioned in the original post, this is to improve an existing system and a solution that does not involve changes to the database schema would be ideal. I think I've found a way forward by adding a column with column_property and then using a synonym to with a

Re: [sqlalchemy] Mixed data type for a column

2015-09-17 Thread Mattias Lagergren
t does not work when mixing data types. Again, thank you for helping! /Mattias L On Wednesday, September 16, 2015 at 5:00:02 PM UTC+2, Michael Bayer wrote: > > > > On 9/16/15 6:46 AM, Mattias Lagergren wrote: > > > The important part is the casting inside

[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

[sqlalchemy] Modified instances from flushed session

2015-06-24 Thread Mattias Lagergren
Hi guys, I'm trying to retrieve modified (new, deleted and dirty) instances from the session, before commit but after a flush. Example: # Update and create objects. ... # This is fine and I have my dirty instances: print session.dirty, session.new, session.deleted session.flush() # At