Mapper issue with r4485

0 views
Skip to first unread message

Steve Zatz

unread,
Apr 10, 2008, 8:46:39 PM4/10/08
to sqlal...@googlegroups.com
I am not sure when the change was introduced but the following mapper,
which previously worked:

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

Michael Bayer

unread,
Apr 11, 2008, 11:10:29 AM4/11/08
to sqlal...@googlegroups.com

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.

Michael Bayer

unread,
Apr 11, 2008, 11:59:06 AM4/11/08
to sqlal...@googlegroups.com

On Apr 10, 2008, at 8:46 PM, Steve Zatz wrote:

my hat's off to you for coming up with that relation(), it works again
in rev 4486.


Steve Zatz

unread,
Apr 11, 2008, 4:08:49 PM4/11/08
to sqlal...@googlegroups.com
> my hat's off to you for coming up with that relation(), it works again
> in rev 4486.
Ah the irony ... check out http://tinyurl.com/6kqv94

And thanks as always for your remarkable responsiveness and for
sqlalchemy. It is indispensible.

Steve

Reply all
Reply to author
Forward
0 new messages