lib/mongo/collection/view/readable.rb in mongo-2.11.0.rc0 vs lib/mongo/collection/view/readable.rb in mongo-2.11.0
- old
+ new
@@ -242,10 +242,13 @@
#
# @return [ Array<Object> ] The list of distinct values.
#
# @since 2.0.0
def distinct(field_name, opts = {})
+ if field_name.nil?
+ raise ArgumentError, 'Field name for distinct operation must be not nil'
+ end
cmd = { :distinct => collection.name,
:key => field_name.to_s,
:query => filter }
cmd[:maxTimeMS] = opts[:max_time_ms] if opts[:max_time_ms]
if read_concern
@@ -600,18 +603,18 @@
:session => session,
}.merge!(options))
cmd.execute(server).cursor_ids.map do |cursor_id|
result = if server.features.find_command_enabled?
Operation::GetMore.new({
- :selector => {:getMore => cursor_id,
+ :selector => {:getMore => BSON::Int64.new(cursor_id),
:collection => collection.name},
:db_name => database.name,
:session => session,
}).execute(server)
else
Operation::GetMore.new({
:to_return => 0,
- :cursor_id => cursor_id,
+ :cursor_id => BSON::Int64.new(cursor_id),
:db_name => database.name,
:coll_name => collection.name
}).execute(server)
end
Cursor.new(self, result, server, session: session)