On Feb 15, 2012, at 12:54 PM, Michael Hipp wrote:

> Doing this to test equality between ORM objects:
> 
>  a = sess1.query(Thing).get(1)
>  b = sess2.query(Thing).get(1)  # different session
> 
> Was somewhat surprised to find that:
>  a == b    gives False
> 
> Is this by design? Do I need to add a custom __eq__ method to my declarative 
> Base classes to make a==b come out True?

Curious, for "a" and "b" to be "equals" without a custom __eq__, that would 
imply that sess1 and sess2 share the same identity map and state, is that what 
you were expecting ?   Or just that SQLAlchemy would automatically instrument 
an __eq__() method on mapped classes ?

Anyway, yeah we don't assume that, so you'd want to implement an __eq__() that 
I'd assume compares primary key values.


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

Reply via email to