Uploaded image for project: 'Mongoid'
  1. Mongoid
  2. MONGOID-5023

Expand all conditions in a single argument together in `where` path

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 7.3.0
    • Affects Version/s: None
    • Component/s: Query
    • None
    • Minor Change

      Existing behavior:

      irb(main):007:0> Band.where(year: 2020, :year.gt => 1960)
      => 
      #<Mongoid::Criteria
        selector: {"year"=>2020, "$and"=>[{"year"=>{"$gt"=>1960}}]}
        options:  {}
        class:    Band
        embedded: false>
      

      Desired behavior:

      irb(main):010:0> Band.where(year: 2020, :year.gt => 1960)
      => 
      #<Mongoid::Criteria
        selector: {"year"=>{"$eq"=>2020, "$gt"=>1960}}
        options:  {}
        class:    Band
        embedded: false>
      
      

      This was already done for `and` in https://jira.mongodb.org/browse/MONGOID-5020, the present ticket covers making the same change for `where` and, as side effects, or/nor/not.

      Also this ticket would fix the following misconstruction in 7.2:

      irb(main):006:0> Band.or(year: 2020, :year.gt => 1960)
      => 
      #<Mongoid::Criteria
        selector: {"$or"=>[{"year"=>{"$gt"=>1960}}]}
        options:  {}
        class:    Band
        embedded: false>
      
      

            Assignee:
            oleg.pudeyev@mongodb.com Oleg Pudeyev (Inactive)
            Reporter:
            oleg.pudeyev@mongodb.com Oleg Pudeyev (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: