Hi list,

Here is my solution (thanks to jek from IRC).

# Mappers
channel_mapper = mapper(Channel, channel_table,
     properties = {
         "playlists":relation(PlaylistChannel,
             backref="channel",
             primaryjoin=and_(channel_table.c.id==
                 playlist_channel_table.c.id_channel)),
         "active":relation(Playlist, post_update=True,
             primaryjoin=and_(channel_table.c.id_playlist==
                 playlist_table.c.id))
     },
     order_by=channel_table.c.name,
)

That is one solution I was actually doing, but it turns out that I 
didn't know about the "post_update" argument... and this is not 
documented anywhere in the docs !

This solution without the argument post_update=True turns out to yield a 
"CircularDependencyError":

sqlalchemy.exceptions.CircularDependencyError: Circular dependency 
detected [(<PlaylistChannel: 2>, <Channel: Test TV>), (<Channel: Test 
TV>, <PlaylistChannel: 1>), (<Channel: Test TV>, <PlaylistChannel: 2>)][]

ps: Ok, this is documented, but we need to look down in the generated 
API documentation of the relation() function. I think this should be 
pushed up somewhere in the docs. Here's a suggestion: 
http://www.sqlalchemy.org/docs/04/mappers.html#advdatamapping_relation_customjoin

Regards,
-- 
Alexandre CONRAD


--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to