Re: [sqlalchemy] Unable to configure Column server_default attribute when using automap

2017-02-01 Thread mike bayer
On 02/01/2017 01:54 PM, derek.mil...@spacex.com wrote: It doesn't appear that the "default" column_info field allows for anything other than a generic default. I currently have the following event handler: | @event.listens_for(Table,'column_reflect')

[sqlalchemy] Re: Autoflush and session.merge with load=False

2017-02-01 Thread Denis Krienbühl
Okay never mind, the behaviour I observed was due to me loading the objects from cache again *after* having changed their attributes - I think. I shall post again if I have to revisit this :) On Wednesday, February 1, 2017 at 12:01:58 PM UTC+1, Denis Krienbühl wrote: > > Hi > > I'm trying to

[sqlalchemy] Autoflush and session.merge with load=False

2017-02-01 Thread Denis Krienbühl
Hi I'm trying to add a somewhat transparent cache to certain SQLAlchemy objects in my application. Not a general query cache, just a cache for often used objects with a Memcached backend. This is all working just as expected with one caveat. After loading an object from the cache I merge it

[sqlalchemy] Re: Duplicate primary key while merging polymorphic relationship

2017-02-01 Thread Shane Carey
I took the SQL into mysql directly to see what may be going wrong, it looks like the generated SELECT thing.id AS thing_id, thing.type_id AS thing_type_id, thing.txt AS thing_txt, (SELECT type.id FROM type WHERE type.id = thing.type_id) AS _sa_polymorphic_on, thing.stuff AS thing_stuff FROM

[sqlalchemy] Duplicate primary key while merging polymorphic relationship

2017-02-01 Thread Shane Carey
I am having a strange issue with merging a polymorphic relationship, I've managed to reduce my problem to this code: from sqlalchemy import * from sqlalchemy import select, and_, event, inspect from sqlalchemy.orm import * from sqlalchemy.ext.declarative import * Base = declarative_base()

Re: [sqlalchemy] Unable to configure Column server_default attribute when using automap

2017-02-01 Thread mike bayer
you would use the column_reflect event and set the value of the "default" in the given dictionary to be your FetchedValue object. On 01/31/2017 05:06 PM, derek.mil...@spacex.com wrote: I am attempting to reflect an existing PostgreSQL database that has triggers setting a version_num column.

[sqlalchemy] Re: Duplicate primary key while merging polymorphic relationship

2017-02-01 Thread Shane Carey
I resolved this issue, it was a misconfiguration of my 'polymorphic_on' On Wednesday, February 1, 2017 at 8:35:59 AM UTC-6, Shane Carey wrote: > > I took the SQL into mysql directly to see what may be going wrong, it > looks like the generated > > SELECT > thing.id AS thing_id, > thing.type_id

Re: [sqlalchemy] Unable to configure Column server_default attribute when using automap

2017-02-01 Thread derek . miller
It doesn't appear that the "default" column_info field allows for anything other than a generic default. I currently have the following event handler: @event.listens_for(Table, 'column_reflect') def _set_fetched_value_for_triggered_columns(inspector, table, column_info): if