From 3a4134a5c28a1d70134558fb4c55ddd58738ac9d Mon Sep 17 00:00:00 2001 From: Kyle Banker Date: Thu, 9 Sep 2010 14:53:29 -0400 Subject: [PATCH] RUBY-180 fixed failing test --- lib/mongo/cursor.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/mongo/cursor.rb b/lib/mongo/cursor.rb index 227cfad..a2e1a04 100644 --- a/lib/mongo/cursor.rb +++ b/lib/mongo/cursor.rb @@ -363,12 +363,12 @@ module Mongo BSON::BSON_RUBY.serialize_cstr(message, "#{@db.name}.#{@collection.name}") # Number of results to return. - if @limit - if (@returned + @batch_size) > @limit - message.put_int(@limit - @returned) - else - message.put_int(@batch_size) + if @limit > 0 + limit = @limit - @returned + if @batch_size > 0 + limit = limit < @batch_size ? limit : @batch_size end + message.put_int(limit) else message.put_int(@batch_size) end @@ -438,7 +438,7 @@ module Mongo end def close_cursor_if_query_complete - if @limit > 0 && @n_received >= @limit + if @limit > 0 && @returned >= @limit close end end