RUBY-356 clarify docs on continue_on_error
This commit is contained in:
parent
bc872b61fd
commit
e4570c133d
@ -333,6 +333,10 @@ module Mongo
|
||||
# @option opts [Boolean] :continue_on_error (+false+) If true, then
|
||||
# continue a bulk insert even if one of the documents inserted
|
||||
# triggers a database assertion (as in a duplicate insert, for instance).
|
||||
# If not using safe mode, the list of ids returned will
|
||||
# include the object ids of all documents attempted on insert, even
|
||||
# if some are rejected on error. When safe mode is
|
||||
# enabled, any error will raise an OperationFailure exception.
|
||||
# MongoDB v2.0+.
|
||||
#
|
||||
# @core insert insert-instance_method
|
||||
|
@ -151,6 +151,19 @@ class TestCollection < Test::Unit::TestCase
|
||||
end
|
||||
end
|
||||
|
||||
def test_bulk_insert
|
||||
@@test.remove
|
||||
docs = []
|
||||
docs << {:foo => 1}
|
||||
docs << {:foo => 2}
|
||||
docs << {:foo => 3}
|
||||
response = @@test.insert(docs)
|
||||
assert_equal 3, response.length
|
||||
assert response.all? {|id| id.is_a?(BSON::ObjectId)}
|
||||
assert_equal 3, @@test.count
|
||||
@@test.remove
|
||||
end
|
||||
|
||||
def test_bulk_insert_with_continue_on_error
|
||||
if @@version >= "2.0"
|
||||
@@test.create_index([["foo", 1]], :unique => true)
|
||||
|
Loading…
Reference in New Issue
Block a user