RowProxy.__eq__() throws unexpected TypeError #2924
Labels
bug
Something isn't working
engine
engines, connections, transactions, isolation levels, execution options
high priority
Milestone
Migrated issue, originally created by Anonymous
(original reporter: elic) As of 0.9, comparing a
sqlalchemy.engine.result.RowProxy
against any non-iterable (e.g. doingRowProxy(...) == 123
) results in a TypeError, rather 0.8's behavior where it would return False. This breaks the normal python behavior where different types can be compared for equality (e.g.assert {} != 5
). I think this was caused by rev 02f21ff.A simple fix would probably be wrapping the existing
RowProxy.__eq__()
in a try/except that catches TypeError, and returns False; though limiting try/except to just thetuple(other)
call would prevent it from masking other unrelated TypeErrors.That changeset also causes
RowProxy() < 5
return a TypeError, but that part seems fine to me, since Python 3 made that an expected behavior of__lt__()
and friends (e.g.None < 1
now returnsTypeError("unorderable types")
).The text was updated successfully, but these errors were encountered: