Scopes ignore procs that return none criteria

XMLWordPrintableJSON

    • Type: Task
    • Resolution: Done
    • Priority: Major - P3
    • 5.0.1
    • Affects Version/s: None
    • Component/s: None
    • None
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      I have a scope that is supposed to conditionally return the none criteria. I noticed that when the none criteria is returned by a lambda (or regular proc via Proc.new), everything in the colllection is returned instead. The scope seems to be completely ignoring the none criteria. I tested this behavior further by making simple named scopes that simply return none and those are also ignored.

      An example:

      class Simple
        include Mongoid::Document
      
        field :name, type: String
      
        scope :nothing, -> { none }
      end
      

      This simple model's nothing scope would return everything in the collection, rather than not hitting the database at all. Outside of scopes, none seems to work as intended. I have also noted that this behavior transfers to {{default_scope}}s as well.

              Assignee:
              Emily Stolfo (Inactive)
              Reporter:
              Valdez42 [X]
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: