The problem was solved by using a join query and then specifying both
foreign keys and the secondary argument to the relation.
Many thanks,
Nathan
secondary = sentences_table.join(tag_table.join(processed_tags_table,
processed_tags_table.c.tag_id == tag_table.c.tag_id),
sentences_table.c.sentence_id ==
tag_table.c.sentence_id)
mapper(Zone, zones_table, properties={
"species":relation(Name,
primaryjoin=zones_table.c.zone_id == secondary.c.sentences_zone_id,
foreign_keys = [ secondary.c.sentences_zone_id, names_table.c.name_id
],
secondary=processed_tags_normalised_table,
viewonly=True)
2009/5/19 Michael Bayer <[email protected]>:
>
>
> On May 18, 2009, at 8:06 PM, Michael Bayer wrote:
>
>>
>> if you want to make a chained join like that, use just primaryjoin(),
>> dont use "secondary", and set viewonly=True.
>
> I might be off on the "dont use secondary" advice. if you do use
> "secondary", "secondary" is the "middle" table, so in this case it
> seems like it would be "tags_table" and the target would be
> "processed_tag_table".
>
>> As an alternative to the above approach, you can also try using
>> traditional relations between each class and use the association proxy
>> to simplify access from one end to the other.
>
> this advice stlll holds though (as does use viewonly=True).
>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---