Operator methods overwrite previous conditions

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Fixed
    • Priority: Major - P3
    • 7.5.0
    • Affects Version/s: None
    • Component/s: None
    • None
    • None
    • Fully Compatible
    • None
    • None
    • None
    • None
    • None
    • None

      When an operator method is called repeatedly it overwrites the previous conditions of the same method. The new conditions should be added to the existing ones.

      Current behavior:

      irb(main):024:0> c=Person.gt(age: 2).gt(age: 1); c
      => 
      #<Mongoid::Criteria
        selector: {"age"=>{"$gt"=>1}}
        options:  {}
        class:    Person
        embedded: false>
      

      Expected something like:

      => 
      #<Mongoid::Criteria
        selector: {"age"=>{"$gt"=>2}, "$and"=>[{"age"=>{"$gt"=>1}}]}
        options:  {}
        class:    Person
        embedded: false>
      

              Assignee:
              Neil Shweky (Inactive)
              Reporter:
              Oleg Pudeyev (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: