- marked as critical
RowProxy.__eq__() throws unexpected TypeError
(original reporter: elic) As of 0.9, comparing a sqlalchemy.engine.result.RowProxy
against any non-iterable (e.g. doing RowProxy(...) == 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 02f21ffcf366da406795334d2fc6908.
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 the tuple(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 returns TypeError("unorderable types")
).
Comments (4)
-
repo owner -
repo owner - changed milestone to 0.9.2
-
repo owner - changed status to resolved
check out how I did this in d4c908ded1e9a7923312f3b33583, I've added test coverage ensuring that all equality operators (==, !=, <, >, <=, >=) should behave identically to that of a tuple. reopen if I got it wrong, thanks!
-
repo owner - removed milestone
Removing milestone: 0.9.2 (automated comment)
- Log in to comment
or just throwing an isinstance() in there.