didnt get your attachment.  but yes, they are different.  during a  
many-to-many flush() operation, the two relationships know to  
communicate which one actually dealt with the row in the many-to-many  
table, without it, youll get duplicate association rows.   
additionally, the automatic management of the bi-directional  
attribute in Python tends to smooth out operations significantly,  
although two separate attributes should still work.  but keep in mind  
if you dont set up "backref", you have to manually assign to each  
collection in both directions.   i dont know why youd want to do it  
that way.

On Mar 27, 2007, at 7:40 AM, Gaetan de Menten wrote:

>
> Hi list,
>
> A while ago, someone came up with a problem on the Elixir list. The
> problem is that in elixir we force users to define relationships on
> both sides of the relationship (ie, there is no concept of backref).
> And I (mistakenly) thought that having two mappers with relations to
> each other was the same as having one mapper with a relation to the
> other and a backref, so I didn't define backrefs for those
> relationships.
>
> It seems like, in fact, it's not exactly the same: the difference seem
> to be with the automatic update of the other attribute (the backref)
> *even before a flush is done*, as demonstrated at:
>
> http://www.sqlalchemy.org/docs/ 
> datamapping.html#datamapping_relations_backreferences
>
> Now the question is: shouldn't these two ways to define relations  
> be equivalent?
>
> Attached is a test case, demonstrating that the second way doesn't
> work (in case it can be of any use).
>
> BTW: there are several mistakes in the example there.
>
> Address = mapper(Address, addresses_table)
> User = mapper(User, users_table, properties = {
>                 'addresses' : relation(Address, backref='user')
>             }
>           )
>
> should read:
>
> mapper(Address, addresses_table)
> mapper(User, users_table, properties = {
>                 'addresses' : relation(Address, backref='user')
>             }
>           )
>
> and
>
>>>> a1.user is user and a2.user is user
> True
>
> should be:
>
>>>> a1.user is u and a2.user is u
> True
>
> -- 
> Gaƫtan de Menten
> http://openhex.org
>
> >


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