@@ -313,10 +313,10 @@ def find_one(spec_or_object_id=nil, opts={})
313313 # @return [ObjectId] the _id of the saved document.
314314 #
315315 # @option opts [Hash] :w, :j, :wtimeout, :fsync Set the write concern for this operation.
316- # :w > 0 will run a +getlasterror+ command on the database to report any assertion.
316+ # :w > 0 will run a +getlasterror+ command on the database to report any assertion.
317317 # :j will confirm a write has been committed to the journal,
318318 # :wtimeout specifies how long to wait for write confirmation,
319- # :fsync will confirm that a write has been fsynced.
319+ # :fsync will confirm that a write has been fsynced.
320320 # Options provided here will override any write concern options set on this collection,
321321 # its database object, or the current connection. See the options
322322 # for DB#get_last_error.
@@ -349,10 +349,10 @@ def save(doc, opts={})
349349 # @option opts [Boolean] :j (false) Set journal acknowledgement
350350 # @option opts [Integer] :wtimeout (nil) Set replica set acknowledgement timeout
351351 # @option opts [Boolean] :fsync (false) Set fsync acknowledgement.
352- #
352+ #
353353 # Notes on write concern:
354354 # Options provided here will override any write concern options set on this collection,
355- # its database object, or the current connection. See the options for +DB#get_last_error+.
355+ # its database object, or the current connection. See the options for +DB#get_last_error+.
356356 #
357357 # @option opts [Boolean] :continue_on_error (+false+) If true, then
358358 # continue a bulk insert even if one of the documents inserted
@@ -369,6 +369,9 @@ def save(doc, opts={})
369369 #
370370 # @core insert insert-instance_method
371371 def insert ( doc_or_docs , opts = { } )
372+ if name . start_with? ( "system." ) && name !~ /(\A system\. users)|(\A system\. indexes)/
373+ raise Mongo ::InvalidNSName , "cannot insert into system collections."
374+ end
372375 doc_or_docs = [ doc_or_docs ] unless doc_or_docs . is_a? ( Array )
373376 doc_or_docs . collect! { |doc | @pk_factory . create_pk ( doc ) }
374377 write_concern = get_write_concern ( opts , self )
0 commit comments