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

Document that or/nor conditions make default scope one of the disjunction branches

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major - P3
    • Resolution: Fixed
    • None
    • 7.4.0
    • Query
    • Fully Compatible

    Description

      If I define a default scope and then use Model.or, the default scope becomes one of the disjunction branches instead of being a top-level condition in addition to whatever was given in the or:

      class Band
        include Mongoid::Document
       
        default_scope -> { where(likes: 2) }
      end
       
      irb(main):001:0> Band.or(likes:3)
      => 
      #<Mongoid::Criteria
        selector: {"$or"=>[{"likes"=>2}, {"likes"=>3}]}
        options:  {}
        class:    Band
        embedded: false>
      

      This also affects nor the same way.

      When this ticket is worked on, "current scope" set with with_scope should be tested in addition to the defaut scope, as well as clearing scopes with unscoped.

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved: