Re: [sqlalchemy] Re: Filter on self referential polymorphic relationship

2017-04-26 Thread mike bayer
thanks for the great test case, makes this easy. The with_polymorphic() function is used for this kind of situation, more common in joined inheritance but since you want to alias here, works for single also: Piece = with_polymorphic(Item, '*', aliased=True) s.query(Item) \ .ou

[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, 'w