Gianluca Magni
Gianluca Magni

Reputation: 13

Mongoid upgrade to 6.1.0 Invalid collection error

I'm developing a rails 5.0.2 application with mongo backend v.3.4 I'm using mongoid as db access gem. Upgrading from mongoid 6.0.x to 6.1.0, my map reduce calculation throws exception :

Mongo::Error::OperationFailure: Invalid collection name: db_development (73)

I can see the exception in my running tests (all green before upgrade). Also trying in console (rails c) gives the same exception.

map = "function() { emit(this.id, 1) }"
reduce = "function(key,values) { return Array.sum(values) }"
mr = qs.map_reduce(map,reduce).out(inline: true)
=> #<Mongoid::Contextual::MapReduce
  selector: {"Book_id"=>BSON::ObjectId('58ef26cf01e5ba1fc2316696')}
  class:    Title
  map:      function() { emit(this.id, 1) }
  reduce:   function(key,values) { return Array.sum(values) }
  finalize: 
  out:      {"inline"=>true}>

mr.each do |m|
  p m
end

Mongo::Error::OperationFailure: Invalid collection name: db_development (73)

Thanks in advance for any help Gianluca

Upvotes: 1

Views: 171

Answers (1)

Ilya K
Ilya K

Reputation: 56

Change "inline"=>true to "inline"=>1. Seems like some undocumented API change happened lately.

Upvotes: 4

Related Questions