From: Philip Jenvey Date: Tue, 21 Jul 2009 00:47:03 +0000 (+0000) Subject: ensure _BindParamClause hash codes are unique on Jython X-Git-Tag: rel_0_6_6~97 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b6384551d46df94386ff01bf193a43815ed4f1d0;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git ensure _BindParamClause hash codes are unique on Jython fixes #1475 --- diff --git a/lib/sqlalchemy/sql/expression.py b/lib/sqlalchemy/sql/expression.py index 8cf6109cae..9eb2926e5b 100644 --- a/lib/sqlalchemy/sql/expression.py +++ b/lib/sqlalchemy/sql/expression.py @@ -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