lib/mongo/collection/view/builder/find_command.rb in mongo-2.4.0.rc0 vs lib/mongo/collection/view/builder/find_command.rb in mongo-2.4.0.rc1

- old
+ new

@@ -94,18 +94,33 @@ private def find_command document = BSON::Document.new('find' => collection.name, 'filter' => filter) command = Options::Mapper.transform_documents(convert_flags(options), MAPPINGS, document) - convert_negative_limit(command) + convert_limit_and_batch_size(command) + command end - def convert_negative_limit(command) - if command[:limit] && command[:limit] < 0 - command['limit'] = command['limit'].abs + def convert_limit_and_batch_size(command) + if command[:limit] && command[:limit] < 0 && + command[:batchSize] && command[:batchSize] < 0 + + command[:limit] = command[:limit].abs + command[:batchSize] = command[:limit].abs command[:singleBatch] = true + + else + [:limit, :batchSize].each do |opt| + if command[opt] + if command[opt] < 0 + command[opt] = command[opt].abs + command[:singleBatch] = true + elsif command[opt] == 0 + command.delete(opt) + end + end + end end - command end def convert_flags(options) return options if options.empty? opts = options.dup