On Nov 5, 2010, at 7:01 AM, Stéphane Klein wrote:
> Hi,
>
> this is a example with « joined table inheritance » feature :
>
> class User(Base):
> __tablename__ = 'users'
>
> id = Column(Integer, primary_key=True)
>
> discriminator = Column('type', String(50))
> __mapper_args__ = {'polymorphic_on': discriminator}
>
> class Contact(Base):
> __tablename__ = 'contacts'
>
> id = Column(Integer, primary_key=True)
>
> discriminator = Column('type', String(50))
> __mapper_args__ = {'polymorphic_on': discriminator}
>
>
> class Employee(Base):
> __tablename__ = 'employees'
> __mapper_args__ = {'polymorphic_identity': 'employee'}
>
> employee_id = Column('id', Integer, ForeignKey('user.id'),
> primary_key=True)
>
>
> class Customer(Base):
> __tablename__ = 'customers'
>
> __mapper_args__ = {'polymorphic_identity': 'customer'}
>
> customer_id = Column('id', Integer, ForeignKey('user.id'),
> primary_key=True)
>
>
> Here Employee and Customer inherit from User class.
> Now I would like append another heritage from Contact, then two
> heritage (User and Contact).
>
> It's possible to do that with SQLAlchemy ?
here's some exposition on mapping multiple inheritance:
http://www.agiledata.org/essays/mappingObjects.html#MappingMultipleInheritance
its not something SQLA has tried to support out of the box. Its quite
complicated. You might be able to approximate it using a combination of
inheritance, relationship(), and association proxies, however.
>
> Thanks for your help.
>
> Regards,
> Stephane
>
> --
> You received this message because you are subscribed to the Google Groups
> "sqlalchemy" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/sqlalchemy?hl=en.
>
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en.