Uploaded image for project: 'Ruby Driver'
  1. Ruby Driver
  2. RUBY-2788

Overrides precedent other '$and' expression

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Unknown Unknown
    • None
    • Affects Version/s: None
    • Component/s: 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 Unassigned
            Reporter:
            pinarello.marvel@gmail.com 英雄 中野
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: