I'm trying to use a relationship that uses a set as the collection_class by 
setting the collection_class parameter to set.

I chose a set since there should only be one instance corresponding to a give 
table row since it is enforced by a foreign key on the many side.

When initially populating the data, I found that I can add two objects that 
were instantiated with the same data. This makes sense because by default when 
Python compares two instances it looks at their object id and since these are 
two separate objects, there is no duplication. I added __hash__, __cmp__ and 
__eq__ methods to the class so that instances with the same data compare equal.

Is this the correct way to use a set as a collection_class?

Thanks,
Mark

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalch...@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to