On 16/02/2010 15:48, Krishnakant Mane wrote:
On Tuesday 16 February 2010 07:01 PM, avdd wrote:
Now the specific problem you see is that the ORM uses the declared
ForeignKeys to determine how to join tables for a relation, but on
your Detail table you have two foreign keys back to account and the
ORM doesn't know which one to use.
Even I have the same problem.
If one table has 2 columns as foreign keys which refer back to one
column in the parent table, how do we sort this problem out?
I did it like this:
class Recipeit(Base):
__table__ = sa.Table(u'recipeit', metadata,
sa.Column(u'recipeitid', sa.Integer(),
sa.Sequence('gen_recipeit_recipeitid'), primary_key=True, nullable=False),
...
sa.Column(u'fk_recipeid', sa.Integer(),
sa.ForeignKey(u'recipe.recipeid'), nullable=False),
sa.Column(u'ot_fk_recipeid', sa.Integer(),
sa.ForeignKey(u'recipe.recipeid')),
...
)
recipe = sao.relation(Recipe, primaryjoin=
('Recipeit.fk_recipeid==Recipe.recipeid'))
ot_recipe = sao.relation(Recipe, primaryjoin=
('Recipeit.ot_fk_recipeid==Recipe.recipeid'))
Werner
--
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.