Undefined method bson_type for Mongoid::Geospatial::Point : Aggregations
wordjelly opened this issue · 1 comments
wordjelly commented
Hi,
This is the stuff I'm running :
Rails : 4.2.10
Mongoid Version : 5.0.2
Mongoid-Geospatial : 5.0.0
Document Setup:
class Workflow::Location
embeds_many :tlocations
field :location, type: Point
end
While performing a $geoNear aggregation as follows:
response = Location.collection.aggregate([{
"$geoNear" => {
"near" => {
"type" => "Point",
"coordinates" => point
},
"spherical" => true,
"query" => {
"$and" => [
{
"tlocations" => {
"booked" => false,
"entity_category" => "1a",
"start_time" => {
"$gte" => time_range[0],
"$lte" => time_range[1]
}
}
},
{
"tlocations" => {
"booked" => false,
"entity_category" => "1",
"start_time" => {
"$gte" => time_range[0],
"$lte" => time_range[1]
}
}
}
]
}
}
}])
When I call :
response.count
I get the error :
undefined method `bson_type' for #<Mongoid::Geospatial::Point:0x0055f2ca5a8ff8>
Any operation on the aggregation response, produces this error. It seems that it is unable to cast the "point" returned in the aggregation response to a Geospatial::Point object. Any help is appreciated, I am totally stuck with this for several hours now.
Bhargav
dblock commented
This is a version incompatibility here, let's close it. I believe it's fixed.