Reference == Int works to build join condition, but Int == Reference fails

Bug #244769 reported by Stuart Bishop on 2008-07-02
This bug affects 1 person
Affects Status Importance Assigned to Milestone

Bug Description

Where is an integer primary key and is a Reference to, the expression == works as expected but == raises a TypeError.

Stuart Bishop (stub) wrote :
James Henstridge (jamesh) wrote :

This is due to choice of the __eq__() method. For " ==", Reference.__eq__() is executed which generates a correct expression object.

For " ==", Comparable.__eq__() is executed, which tries to convert (a Reference object) to an integer, which gives a TypeError. Perhaps some of these rich comparison methods should be returning NotImplemented instead? That would allow Reference.__eq__() to have a go in this second case.

Gustavo Niemeyer (niemeyer) wrote :

As discussed in #627137 (which is probably a duplicate and should be marked as such), == feels a bit strange. I see no clarity wins when compared to == Bar.foo_id. == Foo might be nice, though.

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Duplicates of this bug

Other bug subscribers