In my project, I have users, who receive messages, which can be
assigned any number of 'tags'. (In the same manner as Gmail's labels)
I've got (amongst others) the following tables:
- UserMessages (userId, messageId, ...)
- UserMessageTags (userId, messageId, tagId)
- UserTags (userId, tagId, ...)

 What I'm trying to do is make all UserTags rows available in the
UserMessages objects. At the moment I have:
orm.mapper (UserMessages, userMessagesTable
                ,properties={
                                 'tags': orm.relation(UserTags
                                                ,secondary=userMessageTagsTable
                                                ,primaryjoin=sql.and_(
                                                                 
userMessagesTable.c.userId==userMessageTagsTable.c.userId
                                                                
,userMessagesTable.c.messageId==userMessageTagsTable.c.messageId
                                                                )
                                                ,secondaryjoin=sql.and_(
                                                                 
userMessageTagsTable.c.userId==userTagsTable.c.userId
                                                                
,userMessageTagsTable.c.tagId==userTagsTable.c.tagId
                                                                )
                                                ,lazy=False
                                                ,uselist=True
                                                )
                                }
                )

This works find for reading in the data, but when I attempt to remove
an entry from the list:
userMessage.tags.pop()
session.flush()
I get an:
sqlalchemy.exceptions.InvalidRequestError: Column
'userMessageTags.userId' is not available, due to conflicting property
'userId':<sqlalchemy.orm.properties.ColumnProperty object at
0xb75ba2ac>

 When I changed the primaryjoin and secondaryjoin conditions to only
use messageId and tagId, respectively, it worked as expected. Changing
them to both only use the userId columns caused the same
IvalidRequestError.

 Is this a bug in SA, or in my implementation (which, admittedly, is
usually the case :) )?

 Takk,
 - Mel C


--~--~---------~--~----~------------~-------~--~----~
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