very small fix to _BinaryExpression.compare

Issue #664 resolved
Former user created an issue

Comparing two _BinaryExpressions have not considered that one of them could be reversed, i.e (Column, _BindParamClause) equals (_BindParamClause,Column) patch is simple.

I have found it looking at strange lazy load queries.

Comments (6)

  1. Mike Bayer repo owner

    can you please describe something which you've seen fail without this patch ? some example code would be best.

  2. Mike Bayer repo owner

    not to mention that not all BinaryExpressions are commutative, awareness of this would need to be added.

  3. Former user Account Deleted

    Replying to zzzeek:

    not to mention that not all BinaryExpressions are commutative, awareness of this would need to be added.

    Heh! My fault. Of course, this patch should be used only for commutative operators, like '='.

  4. Former user Account Deleted

    I noticed that some simple lazy loads do not query database, if instance already in session, while others, very similar, still do.

    The bug is that some lazy properties have use_get == False in LazyLoader.init because of uncorrect comparing of BinaryExpressions, where first BinaryExpression is

    left: Column
    operator: '='
    right: _BindParamClause
    

    and second is

    left:_BindParamClause
    operator: '='
    right:Column
    

    and Columns are the same.

    It's seems evedent to me, that for commutative operators, comparing should be commutative too.

  5. Log in to comment