[sqlalchemy] Re: Filter on self referential polymorphic relationship

2017-04-25 Thread Shane Carey
A more complete example from sqlalchemy import * from sqlalchemy.orm import * from sqlalchemy.ext.declarative import * Base = declarative_base() class Item(Base): __tablename__ = 'item' id = Column(Integer, primary_key=True) type = Column(String) __mapper_args__ = { 'polymorphic_on': type,

[sqlalchemy] Re: Filter on self referential polymorphic relationship

2017-04-25 Thread Shane Carey
A more complete example: from sqlalchemy import * from sqlalchemy.orm import * from sqlalchemy.ext.declarative import * Base = declarative_base() class Item(Base): __tablename__ = 'item' id = Column(Integer, primary_key=True) type = Column(String) __mapper_args__ = { 'polymorphic_on': type,

[sqlalchemy] Object Relational Tutorial bug

2017-04-25 Thread xela
Hi--- I set out about 20 minutes ago to learn SQLAlchemy, and the third hit Google gave me was the Object Relational Tutorial: http://docs.sqlalchemy.org/en/latest/orm/tutorial.html Where I stalled on the second sentence of the second paragraph, the intended meaning of which I cannot

[sqlalchemy] Re: Object Relational Tutorial bug

2017-04-25 Thread Jonathan Vanasco
This is referencing a concept in software design termed "opinionated". Do a search for "opinionated framework" or "opinionated software" and this will all probably make sense. -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post example

[sqlalchemy] Filter on self referential polymorphic relationship

2017-04-25 Thread Shane Carey
I have a self referential polymorphic relationship using single table inheritance Base = declarative_base() class Item(Base): __tablename__ = 'item' id = Column(Integer) type = Column(String) __mapper_args__ = { 'polymorphic_on': type, 'with_polymorphic': '*'} class

[sqlalchemy] Re: .one is not returning a KeyedTuple, but a

2017-04-25 Thread Mark Jones
I'm keying off hasattr(obj, 'keys') which is working. Still seems strange that it is returning a non-exported class though. -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post example code, please provide an MCVE: Minimal, Complete, and

Re: [sqlalchemy] eager loading relationships after an initial query?

2017-04-25 Thread Simon King
On Mon, Apr 24, 2017 at 10:26 PM, Jonathan Vanasco wrote: > > On Monday, April 24, 2017 at 4:28:22 PM UTC-4, Mike Bayer wrote: >> >> yeah just load the object again w/ the eagerloads option you want. > > > > Thanks. I was hoping there was a way to just say

Re: [sqlalchemy] eager loading relationships after an initial query?

2017-04-25 Thread Jonathan Vanasco
On Tuesday, April 25, 2017 at 5:50:48 AM UTC-4, Simon King wrote: > > def reload(instance, *options): > session = saorm.object_session(instance) > # TODO: make this generic rather than assuming presence of 'id' column > q = (session.query(type(instance)) >