Hi everybody,I have three classes in my model, which one class inherited by the other two:
class Item(Base): __tablename__ = 'item' id = Column(Integer, primary_key=True) title = Column(Unicode(300)) type = Column(Unicode(50)) __mapper_args__ = { 'polymorphic_on': type } class Note(Item): __tablename__ = 'note' id = Column(Integer, ForeignKey('item.id'), primary_key=True) extra = Column(Text) __mapper_args__ = { 'polymorphic_identity': 'note' } class Task(Item): __tablename__ = 'task' id = Column(Integer, ForeignKey('item.id'), primary_key=True) another_extra = Column(Text) __mapper_args__ = { 'polymorphic_identity': 'task' }So, when I execute `session.query(Item).all()` I get a list that includes both `Note` and `Task` objects, but I don't want that, I want my objects to be the instance of `Item` class and just have `id`, `title`, `type`, not those extra fields. how should I write the query? to clarify more, currently, I get: [ <models.Note object at 0x7f25ac3ffe80>, <models.Task object at 0x7f25ac3ffe80>, <models.Task object at 0x7f25ac3ffe80>, ... ] But I want to get: [ <models.Item object at 0x000000000000>, <models.Item object at 0x000000000000>, <models.Item object at 0x000000000000>, ... ] I have asked the same question in StackOverflow, but still nothing. here is the : Get sqlalchemy base class object instead of children | | | | | | | | | | | Get sqlalchemy base class object instead of children I have three classes in my model, which one class inherited by the other two: class Item(Base): __tablename... | | | -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post example code, please provide an MCVE: Minimal, Complete, and Verifiable Example. See http://stackoverflow.com/help/mcve for a full description. --- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at https://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.