]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
ensure _BindParamClause hash codes are unique on Jython
authorPhilip Jenvey <pjenvey@underboss.org>
Tue, 21 Jul 2009 00:47:03 +0000 (00:47 +0000)
committerPhilip Jenvey <pjenvey@underboss.org>
Tue, 21 Jul 2009 00:47:03 +0000 (00:47 +0000)
fixes #1475

lib/sqlalchemy/sql/expression.py

index 8cf6109cae3fee7f472af91d884f4da0c85d1937..9eb2926e5bdcdc72b134d50c90c740781b94e2d4 100644 (file)
@@ -2121,6 +2121,16 @@ class _BindParamClause(ColumnElement):
         d['value'] = v
         return d
 
+    def __hash__(self):
+        """Return a distinct hash code.
+
+        ColumnOperators have special equality comparisons which makes us
+        rely on _BindParamClauses having unique hash codes for use in
+        hash-based collections. Stock __hash__ doesn't guarantee unique
+        values, particularly on platforms with moving GCs.
+        """
+        return id(self)
+
     def __repr__(self):
         return "_BindParamClause(%r, %r, type_=%r)" % (
             self.key, self.value, self.type