hi all,
I'm having a tricky situation while modeling a database here. first,
i'll just put the code of my two classes / models:
*
**class Resource(Base):**
**
** resource_id = Column(Integer, Sequence, primary_key=True)**
** resource_type_id = Column(Integer, ForeignKey(SomeClass.id),
nullable=False, index=True)**
** p_discriminator = Column(Integer)**
**
** __mapper_args__ = dict(**
** polymorphic_on=p_discriminator,**
** polymorphic_identity=1**
** )**
**
**class ResourceRelationship(Resource):**
**
** resource_id = Column(Integer, ForeignKey(Resource.resource_id),
primary_key=True, index=True)**
** left_resource_id = Column(Integer,
ForeignKey(Resource.resource_id), nullable=True, index=True)**
** right_resource_id = Column(Integer,
ForeignKey(Resource.resource_id), nullable=True, index=True)**
**
** __mapper_args__ = dict(**
** polymorphic_identity=2**
** inherit_condition=(resource_id == Resource.resource_id)**
** )*
ok, nothing fancy but, I would really like to create a unique constraint
on ResourceRelationship, using left_resouce_id, right_resource_id AND
the inherited resource_type_id.
the problem is: i can do that only using concrete inheritance, afaik. i
would not like to do that because i really like the way polymorphic
models work -- and the most important reason: this database is shared
with other applications that would not rely on sqlalchemy to do the
magic of maintain the data integrity.
any tips? :)
my best regards,
richard.
--
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/groups/opt_out.