diff --git a/couchrest.gemspec b/couchrest.gemspec index c037e0e..c5fe71f 100644 --- a/couchrest.gemspec +++ b/couchrest.gemspec @@ -1,6 +1,6 @@ Gem::Specification.new do |s| s.name = %q{couchrest} - s.version = "0.12.4" + s.version = "0.12.5" s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.authors = ["J. Chris Anderson"] diff --git a/lib/couchrest.rb b/lib/couchrest.rb index ee534c2..09b7cf2 100644 --- a/lib/couchrest.rb +++ b/lib/couchrest.rb @@ -25,7 +25,7 @@ require 'couchrest/monkeypatches' # = CouchDB, close to the metal module CouchRest - VERSION = '0.12.4' + VERSION = '0.12.5' autoload :Server, 'couchrest/core/server' autoload :Database, 'couchrest/core/database' diff --git a/lib/couchrest/core/database.rb b/lib/couchrest/core/database.rb index 9e25fc9..c960b81 100644 --- a/lib/couchrest/core/database.rb +++ b/lib/couchrest/core/database.rb @@ -149,16 +149,18 @@ module CouchRest # missing ids, supply one from the uuid cache. # # If called with no arguments, bulk saves the cache of documents to be bulk saved. - def bulk_save (docs = nil) + def bulk_save(docs = nil, use_uuids = true) if docs.nil? docs = @bulk_save_cache @bulk_save_cache = [] end - ids, noids = docs.partition{|d|d['_id']} - uuid_count = [noids.length, @server.uuid_batch_count].max - noids.each do |doc| - nextid = @server.next_uuid(uuid_count) rescue nil - doc['_id'] = nextid if nextid + if (use_uuids) + ids, noids = docs.partition{|d|d['_id']} + uuid_count = [noids.length, @server.uuid_batch_count].max + noids.each do |doc| + nextid = @server.next_uuid(uuid_count) rescue nil + doc['_id'] = nextid if nextid + end end CouchRest.post "#{@root}/_bulk_docs", {:docs => docs} end