but I dont know on the time of query what the type of object it will be. On Tuesday, April 15, 2014 5:06:48 PM UTC+4, Gunnlaugur Briem wrote: > > Hi Pavel, > > You want: s.query(Person).with_polymorphic(Man).get(51) > > Cheers, > > Gulli > > > On Tue, Apr 15, 2014 at 12:59 PM, Pavel Aborilov > <abor...@gmail.com<javascript:> > > wrote: > >> Hello! >> How can I cache query like this: >> session.query(Person).get(51) >> >> where 51 is id of Man >> >> I can't access attribute age of Man without SELECT. >> >> Models: >> >> class Person(Base): >> __tablename__ = 'person' >> id = Column(Integer, primary_key=True) >> name = Column(String(100), nullable=False) >> type = Column(String(50)) >> __mapper_args__ = { >> 'polymorphic_identity': 'object', >> 'polymorphic_on': type >> } >> >> class Man(Person): >> __tablename__ = 'man' >> id = Column(Integer, ForeignKey('person.id'), primary_key=True) >> age = Column(String(100), nullable=False) >> __mapper_args__ = {'polymorphic_identity': 'man'} >> >> -- >> 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+...@googlegroups.com <javascript:>. >> To post to this group, send email to sqlal...@googlegroups.com<javascript:> >> . >> Visit this group at http://groups.google.com/group/sqlalchemy. >> For more options, visit https://groups.google.com/d/optout. >> > >
-- 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 http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.