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

Mongoid::Contextual::Aggregable::Memory should ignore nil and non-numeric values

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Minor - P4 Minor - P4
    • 8.0.1
    • Affects Version/s: None
    • Component/s: Query
    • Minor Change

      In order to be closer to the native database behavior, Mongoid::Contextual::Aggregable::Memory should ignore nil and non-numeric values.

      Suggest to use a lazy map like so:

      def aggregable_values
        self.lazy
             .map{  |doc| doc.public_send(field)  }
             .select{  |val| val && val.is_a?(Numeric)  }
      end

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

              Created:
              Updated:
              Resolved: