Details
-
Bug
-
Resolution: Done
-
Critical - P2
-
2.2.0
-
None
-
Ruby 1.9.3, OSX Mountain Lion
-
ALL
-
Description
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.
|