-
Type:
Bug
-
Resolution: Done
-
Priority:
Major - P3
-
Affects Version/s: None
-
Component/s: None
-
None
I don't understand why the details (read: caveats) of MongoDB are exposed through the Ruby gem. Drivers are supposed to hide those things, not pop up throughout their use.
>> cf.to_mongo
=> <Mongo::Cursor:0x814727b0 namespace='demo_crawl-development.tmp.mr.mapreduce_1282681193_11' @selector={}>
>> cf.to_set
=> #<Set: {}>
>> cf.to_a
Mongo::InvalidOperation: can't call Cursor#to_a on a used cursor
from /usr/local/rvm/gems/ruby-1.9.2-rc2@demo_crawl/gems/mongo-1.0.7/lib/mongo/cursor.rb:198:in `to_a'
from (irb):153
from /usr/local/rvm/gems/ruby-1.9.2-rc2@demo_crawl/gems/railties-3.0.0.rc/lib/rails/commands/console.rb:44:in `start'
from /usr/local/rvm/gems/ruby-1.9.2-rc2@demo_crawl/gems/railties-3.0.0.rc/lib/rails/commands/console.rb:8:in `start'
from /usr/local/rvm/gems/ruby-1.9.2-rc2@demo_crawl/gems/railties-3.0.0.rc/lib/rails/commands.rb:23:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
>> col.find().to_set
=> #<Set: "_id"=>73288.0, "value"=>"false">
Also, as with below, you can say "hurr learn how Mongo works" but it's pretty silly to NOT raise an Exception, at least for the sake of consistency.
>> cf.each
{|coll| puts coll["value"]}false
=> nil
>> cf.each{|coll| puts coll["value"]}
=> nil
>> cf = col.find
=> <Mongo::Cursor:0x80d3e1b0 namespace='demo_crawl-development.tmp.mr.mapreduce_1282681193_11' @selector={}>
>> cf.each
false
=> nil
That said, there's a lot that the Ruby driver can do to make MongoDB more transparent.