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

2016-04-20 Thread Mike Bayer
on the load side in loading.py and on the persistence side in session.py _register_newly_persistent. On 04/20/2016 01:28 PM, Chris Withers wrote: Hey All, Where is InstanceState.key set? I'm looking for the code that builds the key used in the identity_map of the session. Turns out to be

[sqlalchemy] where is InstanceState.key set?

2016-04-20 Thread Chris Withers
Hey All, Where is InstanceState.key set? I'm looking for the code that builds the key used in the identity_map of the session. Turns out to be not so easy to find... Chris -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from

[sqlalchemy] Re: __table_alias__ option

2016-04-20 Thread SPetro
Thank you On Wednesday, April 20, 2016 at 10:25:43 AM UTC-4, SPetro wrote: > > Hi, is possible to have "default" alias for table > > class Cwle(Base): > __tablename__ = 'CardiacWaitListEntry' > __table_alias__ = 'CWLE' > > I know you can do this > Cwle = aliased(Cwle, name='CWLE') > >

Re: [sqlalchemy] Re: __table_alias__ option

2016-04-20 Thread Mike Bayer
if intellisense is scanning source code to determine what elements an object has, then I don't see any way for it to do this unless you actually typed in a new definition of some kind that laid out all the attributes you'd like intellisense to know about. IMO such tools are not practical

[sqlalchemy] Re: __table_alias__ option

2016-04-20 Thread SPetro
Hi , but how would you write query with this, this is what I want class Cwle(Base): __tablename__ = 'CardiacWaitListEntry' wleid = Column('WaitlistEntryID',NUMERIC(18), primary_key=True) qr = session.query(Cwle.wleid) <--- when I type Cwle. it will bring intellisense with all columns

Re: [sqlalchemy] __table_alias__ option

2016-04-20 Thread Mike Bayer
from sqlalchemy.orm import aliased as _aliased def aliased(entity): return _aliased(entity, name=entity.__table_alias__) ? On 04/20/2016 10:25 AM, SPetro wrote: Hi, is possible to have "default" alias for table class Cwle(Base): __tablename__ = 'CardiacWaitListEntry'

[sqlalchemy] __table_alias__ option

2016-04-20 Thread SPetro
Hi, is possible to have "default" alias for table class Cwle(Base): __tablename__ = 'CardiacWaitListEntry' __table_alias__ = 'CWLE' I know you can do this Cwle = aliased(Cwle, name='CWLE') but this screw up any editor intellisense. Output of sqalchemy query would be more readable

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

2016-04-20 Thread Mike Bayer
On 04/20/2016 07:35 AM, Piotr Dobrogost wrote: Having this code class Base(object): @declared_attr def __tablename__(cls): return '{0}s'.format(camel_case_to_name(cls.__name__)) class Model(Base): id = Column(Integer, Sequence(???, optional=True), primary_key=True) is

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

2016-04-20 Thread Ben Sizer
I had an unnamed UniqueConstraint, and autogenerated upgrade scripts that passed in None as the name - these worked perfectly. Now I am discovering that the downgrade doesn't work, as there is no name to refer to the constraint (i.e. "sqlalchemy.exc.CompileError: Can't emit DROP CONSTRAINT for

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

2016-04-20 Thread Piotr Dobrogost
Having this code class Base(object): @declared_attr def __tablename__(cls): return '{0}s'.format(camel_case_to_name(cls.__name__)) class Model(Base): id = Column(Integer, Sequence(???, optional=True), primary_key=True) is there a way to use name of Model's table inside