mapper(Section, section_table, properties = {'items': relation(Item,
backref='section'), 'keywords':relation(Keyword,
primaryjoin=and_(keyword_table.c.uuid==itemkeyword_table.c.keyword_uuid,
item_table.c.uuid==itemkeyword_table.c.item_uuid,
section_table.c.id==item_table.c.section_id), viewonly=True,
foreign_keys=[keyword_table.c.uuid],
remote_side=[item_table.c.section_id])})
now produces the following error:
sqlalchemy.exceptions.ArgumentError: Could not determine relation
direction for primaryjoin condition 'keyword.uuid =
item_keyword.keyword_uuid AND item.uuid = item_keyword.item_uuid AND
section.id = item.section_id', on relation Section.keywords (Keyword).
Specify the foreign_keys argument to indicate which columns on the
relation are foreign.
I am not sure what needs modification in the mapper to be compatible
with the current trunk.
Steve
I've added this example as a unit test and will have to relax the
"viewonly" rules a bit more to handle this - the "primaryjoin along
many tables" use case which is not that unusual. I'll get back to you
shortly.
my hat's off to you for coming up with that relation(), it works again
in rev 4486.
And thanks as always for your remarkable responsiveness and for
sqlalchemy. It is indispensible.
Steve