Hi
I have done the following:
class Affiliation(Base):
__tablename__ = "affiliations"
Id = Column(Integer, primary_key=True)
FullName = Column(Unicode(255), index = True)
discriminator = Column('type', Unicode(20))
__mapper_args__ = {'polymorphic_on': discriminator}
class Person(Affiliation):
__tablename__ = 'persons'
__mapper_args__ = {'polymorphic_identity' : u'person'}
Id = Column(Integer,ForeignKey('affiliations.Id'),
primary_key=True)
class Company(Affiliation):
__tablename__ = 'companies'
__mapper_args__ = {'polymorphic_identity' : u'company'}
Id = Column(Integer,ForeignKey('affiliations.Id'),
primary_key=True)
which is straight foreward.
What I want do do now is a bit more troublesome, I have been trying many
different things but....
class relation(Base):
Parent = reference to one of the Affiliations
Child = reference to one of the Affiliations
Relation_type = column(Integer) (like two persons can
be Father and Son, Two companies can be supplier and customer)
It would be very nice if I can change the Affiliation class to self reference
M:N
Problem with this is that both Parent and child (or "left and right "side")
have to be checked and updated
Martijn
--
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.