Re: [sqlalchemy] where is InstanceState.key set?

2016-04-21 Thread Mike Bayer
On 04/21/2016 07:22 AM, Chris Withers wrote: I ended up going with https://github.com/cjw296/chide/blob/master/chide/sqlalchemy.py#L26 having read those. Sounds about right? oh. I thought you wanted the code that *assigned* state.key. The code to just figure out what the key should be is

[sqlalchemy] chide 2.0.0 released! - sample objects for tests

2016-04-21 Thread Chris Withers
Hi All, I've just released a new version of this tiny library for making sample objects for testing. Here's a SQLAlchemy example: class Parent(Base): __tablename__ = 'parent' id = Column(Integer, primary_key=True) child_id = Column(Integer,

Re: [sqlalchemy] where is InstanceState.key set?

2016-04-21 Thread Chris Withers
I ended up going with https://github.com/cjw296/chide/blob/master/chide/sqlalchemy.py#L26 having read those. Sounds about right? On 21/04/2016 00:23, Mike Bayer wrote: on the load side in loading.py and on the persistence side in session.py _register_newly_persistent. On 04/20/2016

Re: [sqlalchemy] Accessing name of the table in class' attributes.

2016-04-21 Thread Piotr Dobrogost
On Wednesday, April 20, 2016 at 3:38:01 PM UTC+2, Mike Bayer wrote: > > > you can put "id" in declared_attr, should work: > > class Model(Base): > @declared_attr > def id(cls): > return Column(Integer, Sequence(cls.__tablename__ + "id_seq"), > ...) > Id does not work due

Re: How to handle changing formerly-unnamed constraints (and retrying after errors in migration scripts)

2016-04-21 Thread Ben Sizer
Aha, thanks for that. For the benefit of anyone who comes across this later, my final script looked much like this: def downgrade(): try: inner_transaction = op.get_bind().begin_nested() # establish a savepoint with op.batch_alter_table("user_authentication_method") as