RUBY-341 fix :max_scan and :show_disk_loc

This commit is contained in:
Kyle Banker 2011-11-15 16:24:21 -05:00
parent c69bfc6c13
commit 1146e5692a
3 changed files with 25 additions and 4 deletions

View File

@ -217,7 +217,7 @@ module Mongo
max_scan = opts.delete(:max_scan)
return_key = opts.delete(:return_key)
transformer = opts.delete(:transformer)
show_disk_loc = opts.delete(:max_scan)
show_disk_loc = opts.delete(:show_disk_loc)
read = opts.delete(:read) || @read_preference
if timeout == false && !block_given?

View File

@ -26,7 +26,7 @@ module Mongo
attr_reader :collection, :selector, :fields,
:order, :hint, :snapshot, :timeout,
:full_collection_name, :transformer,
:options, :cursor_id
:options, :cursor_id, :show_disk_loc
# Create a new cursor.
#
@ -600,7 +600,7 @@ module Mongo
spec['$hint'] = @hint if @hint && @hint.length > 0
spec['$explain'] = true if @explain
spec['$snapshot'] = true if @snapshot
spec['$maxscan'] = @max_scan if @max_scan
spec['$maxScan'] = @max_scan if @max_scan
spec['$returnKey'] = true if @return_key
spec['$showDiskLoc'] = true if @show_disk_loc
spec
@ -608,7 +608,8 @@ module Mongo
# Returns true if the query contains order, explain, hint, or snapshot.
def query_contains_special_fields?
@order || @explain || @hint || @snapshot
@order || @explain || @hint || @snapshot || @show_disk_loc ||
@max_scan || @return_key
end
def close_cursor_if_query_complete

View File

@ -705,6 +705,26 @@ class TestCollection < Test::Unit::TestCase
coll.ensure_index([['a', 1]])
end
if @@version > '2.0.0'
def test_show_disk_loc
@@test.save({:a => 1})
@@test.save({:a => 2})
assert @@test.find({:a => 1}, :show_disk_loc => true).show_disk_loc
assert @@test.find({:a => 1}, :show_disk_loc => true).next['$diskLoc']
@@test.remove
end
def test_max_scan
1000.times do |n|
@@test.save({:a => n})
end
assert @@test.find({:a => 999}).next
assert !@@test.find({:a => 999}, :max_scan => 500).next
@@test.remove
end
end
context "Grouping" do
setup do
@@test.remove