Hi,
I have two models, A and B. Model B contains two foreign keys into table
A, because it is a "comparator" model that describes certain logical
interaction between two A models. However, I want model B to contain a
relationship to both so I can access them through the model B instance:
class ModelB(Base):
__tablename__ = ...
id_b = ... # primary
some_comparison_data = ...
main_model_id = Column(Integer, ForeignKey("models_a.id_a",
ondelete="cascade", onupdate="cascade"))
duplicate_model_id = Column(Integer, ForeignKey("models_a.id_a",
ondelete="cascade", onupdate="cascade"))
main_model = relationship("ModelA", foreign_keys=[ ??? ],
lazy="joined")
duplicate_model = relationship("ModelA", foreign_keys=[ ??? ],
lazy="joined")
ModelA has no keys back to B, this is basically a "one-to-two"
relationship from B to A.
Now as you can see I don't know what to specify for foreign keys. I
tried with foreign_keys=[main_model_id] and
foreign_keys=[duplicate_model_id] but it complains it couldn't
determine join condition and that I should use primaryjoin. Evenso I
wouldn't know how to use it because I don't know what to specify:
class variable? a string? The examples in the docs are not for
declarative...
Thanks.
--
.oO V Oo.
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com.
To unsubscribe from this group, send email to
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en.