the error youre getting typically occurs when theres more than one
instance of a userMessageTags.c.userId Column instance. how there
might be more than one of the same Column instance can sometimes
happen when using table reflection and things get confused...although
I was pretty sure I had fixed all the issues with that.
so i would ask that you are on the latest version of SA (0.3.5), and
also let me know if youre using "autoload=True" to get your tables,
as well as any other tricks you might be doing with Table/MetaData,
and otherwise try to send me a reproducing test case. The joins you
are using should be valid, and i would suspect they are not the
problem, but are just leading to what the problem actually is; I
made a test program on this end using a many-to-many table with four
columns and it works.
On Mar 16, 2007, at 4:12 AM, Mel Collins wrote:
>
> 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.message
> Id
> )
> ,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 [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
-~----------~----~----~----~------~----~------~--~---