@@ -40,6 +40,7 @@ def initialize(collection, opts={})
4040 @cursor_id = opts . delete ( :cursor_id )
4141 @db = collection . db
4242 @collection = collection
43+ @ns = opts . delete ( :ns )
4344 @connection = @db . connection
4445 @logger = @connection . logger
4546
@@ -83,7 +84,6 @@ def initialize(collection, opts={})
8384
8485 batch_size ( opts . delete ( :batch_size ) || 0 )
8586
86- @full_collection_name = "#{ @collection . db . name } .#{ @collection . name } "
8787 @cache = opts . delete ( :first_batch ) || [ ]
8888 @returned = 0
8989
@@ -124,6 +124,10 @@ def alive?
124124 @cursor_id && @cursor_id != 0
125125 end
126126
127+ def full_collection_name
128+ @ns || "#{ @collection . db . name } .#{ @collection . name } "
129+ end
130+
127131 # Get the next document specified the cursor options.
128132 #
129133 # @return [Hash, Nil] the next document or Nil if no documents remain.
@@ -580,7 +584,7 @@ def send_get_more
580584 message = BSON ::ByteBuffer . new ( [ 0 , 0 , 0 , 0 ] )
581585
582586 # DB name.
583- BSON ::BSON_RUBY . serialize_cstr ( message , " #{ @db . name } . #{ @collection . name } " )
587+ BSON ::BSON_RUBY . serialize_cstr ( message , full_collection_name )
584588
585589 # Number of results to return.
586590 if @limit > 0
@@ -636,7 +640,7 @@ def checkin_socket(sock)
636640 def construct_query_message
637641 message = BSON ::ByteBuffer . new ( "" , @connection . max_bson_size + MongoClient ::COMMAND_HEADROOM )
638642 message . put_int ( @options )
639- BSON ::BSON_RUBY . serialize_cstr ( message , " #{ @db . name } . #{ @collection . name } " )
643+ BSON ::BSON_RUBY . serialize_cstr ( message , full_collection_name )
640644 message . put_int ( @skip )
641645 @batch_size > 1 ? message . put_int ( @batch_size ) : message . put_int ( @limit )
642646 if query_contains_special_fields? && @bson # costs two serialize calls
0 commit comments