From: Philip Jenvey Date: Wed, 22 Jul 2009 02:35:15 +0000 (+0000) Subject: apply the unique __hash__ workaround to all ClauseElements, and only apply it on... X-Git-Tag: rel_0_6_6~86 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=054020a50f9bc082c3fc382be2aacce5c2dbc868;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git apply the unique __hash__ workaround to all ClauseElements, and only apply it on Jython fixes #1475 --- diff --git a/lib/sqlalchemy/sql/expression.py b/lib/sqlalchemy/sql/expression.py index 9eb2926e5b..6c116e5bc0 100644 --- a/lib/sqlalchemy/sql/expression.py +++ b/lib/sqlalchemy/sql/expression.py @@ -1260,6 +1260,17 @@ class ClauseElement(Visitable): def __invert__(self): return self._negate() + if util.jython: + def __hash__(self): + """Return a distinct hash code. + + ClauseElements may have special equality comparisons which + makes us rely on them having unique hash codes for use in + hash-based collections. Stock __hash__ doesn't guarantee + unique values on platforms with moving GCs. + """ + return id(self) + def _negate(self): if hasattr(self, 'negation_clause'): return self.negation_clause @@ -2121,16 +2132,6 @@ 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