summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/sql/util.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2011-07-24 20:41:42 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2011-07-24 20:41:42 -0400
commit5c7cc274250c54430d9dceb05ad2a4a33e2378d7 (patch)
tree44afa2213090a2f19fccd3951de70a961008c83c /lib/sqlalchemy/sql/util.py
parent027725fc49df85d3d9628a006b1c648a6b93f8c3 (diff)
downloadsqlalchemy-5c7cc274250c54430d9dceb05ad2a4a33e2378d7.tar.gz
- rework Annotated to no longer use __cmp__(), supply an __eq__() that
works with ColumnElement as well as works with non-__eq__() suppliers, works with sets, on Py3K as well.
Diffstat (limited to 'lib/sqlalchemy/sql/util.py')
-rw-r--r--lib/sqlalchemy/sql/util.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/sqlalchemy/sql/util.py b/lib/sqlalchemy/sql/util.py
index ed0afef24..fa65070aa 100644
--- a/lib/sqlalchemy/sql/util.py
+++ b/lib/sqlalchemy/sql/util.py
@@ -369,8 +369,12 @@ class Annotated(object):
def __hash__(self):
return hash(self.__element)
- def __cmp__(self, other):
- return cmp(hash(self.__element), hash(other))
+ def __eq__(self, other):
+ if isinstance(self.__element, expression.ColumnOperators):
+ return self.__element.__class__.__eq__(self, other)
+ else:
+ return hash(other) == hash(self)
+
# hard-generate Annotated subclasses. this technique
# is used instead of on-the-fly types (i.e. type.__new__())