RUBY-341 fix :max_scan and :show_disk_loc
This commit is contained in:
parent
c69bfc6c13
commit
1146e5692a
|
@ -217,7 +217,7 @@ module Mongo
|
||||||
max_scan = opts.delete(:max_scan)
|
max_scan = opts.delete(:max_scan)
|
||||||
return_key = opts.delete(:return_key)
|
return_key = opts.delete(:return_key)
|
||||||
transformer = opts.delete(:transformer)
|
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
|
read = opts.delete(:read) || @read_preference
|
||||||
|
|
||||||
if timeout == false && !block_given?
|
if timeout == false && !block_given?
|
||||||
|
|
|
@ -26,7 +26,7 @@ module Mongo
|
||||||
attr_reader :collection, :selector, :fields,
|
attr_reader :collection, :selector, :fields,
|
||||||
:order, :hint, :snapshot, :timeout,
|
:order, :hint, :snapshot, :timeout,
|
||||||
:full_collection_name, :transformer,
|
:full_collection_name, :transformer,
|
||||||
:options, :cursor_id
|
:options, :cursor_id, :show_disk_loc
|
||||||
|
|
||||||
# Create a new cursor.
|
# Create a new cursor.
|
||||||
#
|
#
|
||||||
|
@ -600,7 +600,7 @@ module Mongo
|
||||||
spec['$hint'] = @hint if @hint && @hint.length > 0
|
spec['$hint'] = @hint if @hint && @hint.length > 0
|
||||||
spec['$explain'] = true if @explain
|
spec['$explain'] = true if @explain
|
||||||
spec['$snapshot'] = true if @snapshot
|
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['$returnKey'] = true if @return_key
|
||||||
spec['$showDiskLoc'] = true if @show_disk_loc
|
spec['$showDiskLoc'] = true if @show_disk_loc
|
||||||
spec
|
spec
|
||||||
|
@ -608,7 +608,8 @@ module Mongo
|
||||||
|
|
||||||
# Returns true if the query contains order, explain, hint, or snapshot.
|
# Returns true if the query contains order, explain, hint, or snapshot.
|
||||||
def query_contains_special_fields?
|
def query_contains_special_fields?
|
||||||
@order || @explain || @hint || @snapshot
|
@order || @explain || @hint || @snapshot || @show_disk_loc ||
|
||||||
|
@max_scan || @return_key
|
||||||
end
|
end
|
||||||
|
|
||||||
def close_cursor_if_query_complete
|
def close_cursor_if_query_complete
|
||||||
|
|
|
@ -705,6 +705,26 @@ class TestCollection < Test::Unit::TestCase
|
||||||
coll.ensure_index([['a', 1]])
|
coll.ensure_index([['a', 1]])
|
||||||
end
|
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
|
context "Grouping" do
|
||||||
setup do
|
setup do
|
||||||
@@test.remove
|
@@test.remove
|
||||||
|
|
Loading…
Reference in New Issue