Overrides precedent other '$and' expression

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Duplicate
    • Priority: Unknown
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      I've met the problem that the later expression is overriding precedent other '$and' expressions if expressions are appeared in the specific oder like this:

       

      # this is OK
      Band.where(id: 1).where(id: 2).selector
      => {"_id"=>1, "$and"=>[{"_id"=>2}]}
      
      # this is also OK
      Band.and({year: {'$in' => [2020]}}, {year: {'$in' => [2020]}}).selector
      => {"year"=>{"$in"=>[2020]}, "$and"=>[{"year"=>{"$in"=>[2020]}}]}
      
      # But this is bad, I think
      Band.where(id: 1).and({year: {'$in' => [2020]}}, {year: {'$in' => [2020]}}).where(id: 2).selector
      => {"_id"=>1, "year"=>{"$in"=>[2020]}, "$and"=>[{"_id"=>2}]}
      

      This is happening from version 7.1

              Assignee:
              Unassigned
              Reporter:
              英雄 中野
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: