@@ -313,10 +313,10 @@ def find_one(spec_or_object_id=nil, opts={})
313
313
# @return [ObjectId] the _id of the saved document.
314
314
#
315
315
# @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.
317
317
# :j will confirm a write has been committed to the journal,
318
318
# :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.
320
320
# Options provided here will override any write concern options set on this collection,
321
321
# its database object, or the current connection. See the options
322
322
# for DB#get_last_error.
@@ -349,10 +349,10 @@ def save(doc, opts={})
349
349
# @option opts [Boolean] :j (false) Set journal acknowledgement
350
350
# @option opts [Integer] :wtimeout (nil) Set replica set acknowledgement timeout
351
351
# @option opts [Boolean] :fsync (false) Set fsync acknowledgement.
352
- #
352
+ #
353
353
# Notes on write concern:
354
354
# 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+.
356
356
#
357
357
# @option opts [Boolean] :continue_on_error (+false+) If true, then
358
358
# continue a bulk insert even if one of the documents inserted
@@ -369,6 +369,9 @@ def save(doc, opts={})
369
369
#
370
370
# @core insert insert-instance_method
371
371
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
372
375
doc_or_docs = [ doc_or_docs ] unless doc_or_docs . is_a? ( Array )
373
376
doc_or_docs . collect! { |doc | @pk_factory . create_pk ( doc ) }
374
377
write_concern = get_write_concern ( opts , self )
0 commit comments