Hi when I try to do continue on error for insert many it doesnt work in mongoid.
I set the following unique index
db.push_notifications.createIndex({ actor_vid: 1,campaign_id: 1 },{ unique: true, partialFilterExpression: { campaign_id: { $exists: true } } })
PushNotification.collection.insert_many([{:campaign_id => "1",:actor_vid => 9},{:campaign_id => "1",:actor_vid => 8}],:continue_on_error => true, :safe => false)
PushNotification.collection.insert_many([{:campaign_id => "1",:actor_vid => 9},{:campaign_id => "1",:actor_vid => 10}],:continue_on_error => true, :safe => false) throws
Mongo::Error::BulkWriteError: Mongo::Error::BulkWriteError from /home/deploy/.bundler/notification_service/ruby/2.2.0/gems/mongo-2.2.5/lib/mongo/bulk_write/result.rb:184:in validate!' from /home/deploy/.bundler/notification_service/ruby/2.2.0/gems/mongo-2.2.5/lib/mongo/bulk_write/result_combiner.rb:73:in
result' from /home/deploy/.bundler/notification_service/ruby/2.2.0/gems/mongo-2.2.5/lib/mongo/bulk_write.rb:65:in execute' from /home/deploy/.bundler/notification_service/ruby/2.2.0/gems/mongo-2.2.5/lib/mongo/collection.rb:385:in
bulk_write' from /home/deploy/.bundler/notification_service/ruby/2.2.0/gems/mongo-2.2.5/lib/mongo/collection.rb:363:in insert_many' from /home/deploy/.bundler/notification_service/ruby/2.2.0/gems/mongoid-5.1.3/lib/mongoid/query_cache.rb:168:in
insert_many_with_clear_cache' from (irb):133 from /home/deploy/.bundler/notification_service/ruby/2.2.0/gems/railties-4.2.6/lib/rails/commands/console.rb:110:in start' from /home/deploy/.bundler/notification_service/ruby/2.2.0/gems/railties-4.2.6/lib/rails/commands/console.rb:9:in
start' from /home/deploy/.bundler/notification_service/ruby/2.2.0/gems/railties-4.2.6/lib/rails/commands/commands_tasks.rb:68:in console' from /home/deploy/.bundler/notification_service/ruby/2.2.0/gems/railties-4.2.6/lib/rails/commands/commands_tasks.rb:39:in
run_command!' from /home/deploy/.bundler/notification_service/ruby/2.2.0/gems/railties-4.2.6/lib/rails/commands.rb:17:in <top (required)>' from script/rails:6:in
require' from script/rails:6:in `'
Aucun commentaire:
Enregistrer un commentaire