Bugs item #1839646, was opened at 2007-11-27 20:33
Message generated for change (Comment added) made by phd
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=540672&aid=1839646&group_id=74338
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: General
Group: SQLObject release (specify)
>Status: Closed
>Resolution: Accepted
Priority: 5
Private: No
Submitted By: Peter Russell (psr)
>Assigned to: Oleg Broytmann (phd)
Summary: SQLObject instances of same class with same ID should be ==
Initial Comment:
I've got a failing unittest in some code where I assert that:
group in member.groups
where Group and Member are InheritableSQLObject classes, related by a RelatedJoin. The test loads group and member, then calls the "add a member to a group" controller of my web app, to add the member to the group.
The assertion fails despite the controller working correctly, because SQLObject doesn't override __eq__ to ensure that two different python instances pointing at the same row are equal.
Presumably adding the following to the definition of SQLObject would work
def __eq__(self, other):
if self.__class__ == other.__class__:
if self.id == other.id:
return True
return False
This is occuring with an SQLite in-memory database, with SQLObject 0.7.7 (I know I should upgrade!)
----------------------------------------------------------------------
>Comment By: Oleg Broytmann (phd)
Date: 2007-12-26 15:33
Message:
Logged In: YES
user_id=4799
Originator: NO
Implemented in the trunk. I added all rich comparison methods and a test.
Committed to the trunk at the revision 3184. Will be in SQLObject 0.10.
Thank you!
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=540672&aid=1839646&group_id=74338
|