Thank you Mike !

Le mardi 20 juin 2017 21:23:01 UTC+3, Mike Bayer a écrit :
>
>
>
> On 06/20/2017 02:08 PM, yoch....@gmail.com <javascript:> wrote: 
> > Hi, 
> > 
> > I wish to have a two-levels inheritance, but I don't know how to 
> proceed. 
> > The docs says that "only one discriminator column or SQL expression may 
> > be configured for the entire inheritance hierarchy". 
> > 
> > I tried with this example (mixing joined and single inheritances) : 
> > 
> > | 
> > classPerson(Base): 
> >      __tablename__ ='person' 
> > 
> >      id =Column(Integer,primary_key=True) 
> >      type =Column(String(50),nullable=False) 
> >      name =Column(String(50)) 
> > 
> >      __mapper_args__ ={ 
> > 'polymorphic_identity':'person', 
> > 'polymorphic_on':type 
> > } 
> > 
> > classManager(Person): 
> >      __tablename__ ='manager' 
> > 
> >      id =Column(ForeignKey('person.id'),primary_key=True) 
> >      manager_name =Column(String(30)) 
> > 
> >      __mapper_args__ ={ 
> > 'polymorphic_identity':'manager', 
> > } 
> > 
> > classEngineerBase(Person): 
> >      __tablename__ ='engineer' 
> > 
> >      id =Column(ForeignKey('person.id'),primary_key=True) 
> >      engineer_name =Column(String(30)) 
> > 
> > classEngineerType1(EngineerBase): 
> > 
> >      __mapper_args__ ={ 
> > 'polymorphic_identity':'engineer_t1', 
> > } 
> > 
> > classEngineerType2(EngineerBase): 
> > 
> >      __mapper_args__ ={ 
> > 'polymorphic_identity':'engineer_t2', 
> > } 
> > | 
> > 
> > It seems to work, but it this correct ? 
>
> it's correct, you only have one "polymorphic_on" set up, and that's what 
> that means. 
>
>
> > 
> > -- 
> > 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+...@googlegroups.com <javascript:> 
> > <mailto:sqlalchemy+unsubscr...@googlegroups.com <javascript:>>. 
> > To post to this group, send email to sqlal...@googlegroups.com 
> <javascript:> 
> > <mailto:sqlal...@googlegroups.com <javascript:>>. 
> > Visit this group at https://groups.google.com/group/sqlalchemy. 
> > For more options, visit https://groups.google.com/d/optout. 
>

-- 
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.

Reply via email to