[Sqlalchemy-tickets] [sqlalchemy] #2924: RowProxy.__eq__() throws unexpected TypeError
Brought to you by:
zzzeek
|
From: sqlalchemy <mi...@zz...> - 2014-01-28 06:06:57
|
#2924: RowProxy.__eq__() throws unexpected TypeError
--------------------+-----------------------------------------
Reporter: elic | Owner: zzzeek
Type: defect | Status: new
Priority: medium | Milestone: 0.9.xx
Component: engine | Severity: no triage selected yet
Keywords: | Progress State: awaiting triage
--------------------+-----------------------------------------
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")`).
--
Ticket URL: <http://www.sqlalchemy.org/trac/ticket/2924>
sqlalchemy <http://www.sqlalchemy.org/>
The Database Toolkit for Python
|