1. Michael Bayer
  2. sqlalchemy
  3. Issues


Issue #2924 resolved

RowProxy.__eq__() throws unexpected TypeError

Anonymous created an issue

(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)

  1. Log in to comment