Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-7185

Aggregation should support Symbol type

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Critical - P2 Critical - P2
    • 2.3.2
    • Affects Version/s: 2.2.0
    • Component/s: Aggregation Framework
    • Labels:
      None
    • Environment:
      Ruby 1.9.3, OSX Mountain Lion
    • ALL
    • Hide

      Renaming to reflect scope of issue (not just $group)

      Show
      Renaming to reflect scope of issue (not just $group)

      I'm getting an error in aggregation framework for a field that is stored as BSON Symbol using Mongoid's `symbolize` method.

      Any way around this besides not storing the data as a symbol? The bad field below is '$bucket_type'

       
      class TestAggregation
        def self.data
          command = {
            aggregate: 'cohort_generics',
            pipeline: [
              {
                '$match' => {
                  product_id: 2,
                  created_at: {
                    '$gte' => 1.month.ago
                  }
                }
              },
              {
                '$group' => {
                  _id: {
                    startDate: '$start_date',
                    type: '$_type',
                    bucket_type: '$bucket_type'
                  },
                  people: { '$sum' => 1 }
                }
              }
            ]
          }
      
          Mongoid.default_session.command(command)['result']
        end
      end
      
      Moped::Errors::OperationFailure: The operation: #<Moped::Protocol::Command
        @length=290
        @request_id=2
        @response_to=0
        @op_code=2004
        @flags=[]
        @full_collection_name="usercycle.$cmd"
        @skip=0
        @limit=-1
        @selector={:aggregate=>"cohort_generics", :pipeline=>[{"$match"=>{:product_id=>2, :created_at=>{"$gte"=>Mon, 27 Aug 2012 18:07:53 UTC +00:00}}}, {"$group"=>{:_id=>{:startDate=>"$start_date", :type=>"$_type", :bucket_type=>"$bucket_type"}, :people=>{"$sum"=>1}}}]}
        @fields=nil>
      failed with error 16002: "exception: can't create Value of BSON type Symbol"
      
      See https://github.com/mongodb/mongo/blob/master/docs/errors.md
      for details about this error.
      

            Assignee:
            mathias@mongodb.com Mathias Stearn
            Reporter:
            rywalker Ry Walker
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: