Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fix errors when fetching deleted documents using the bulk api #66

Closed
wants to merge 2 commits into from

1 participant

@matthiasjakel

When you try to fetch a deleted document, the doc attribute is set but has the value null. My commit fixes that and avoids the following exception 'NoMethodError: undefined method `database=' for nil:NilClass'.

matthiasjakel added some commits
@matthiasjakel matthiasjakel Make therubyracer a runtime dependency to fix load errors (v8) f98362c
@matthiasjakel matthiasjakel Fix errors when fetching deleted documents using the bulk api
When you try to fetch a deleted document the doc attribute is set but has the value null. My commit fixes that and avoids the following exception 'NoMethodError: undefined method `database=' for nil:NilClass'.
347fb94
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 24, 2012
  1. @matthiasjakel
Commits on Jun 19, 2012
  1. @matthiasjakel

    Fix errors when fetching deleted documents using the bulk api

    matthiasjakel authored
    When you try to fetch a deleted document the doc attribute is set but has the value null. My commit fixes that and avoids the following exception 'NoMethodError: undefined method `database=' for nil:NilClass'.
This page is out of date. Refresh to see the latest.
View
12 Gemfile.lock
@@ -5,14 +5,15 @@ PATH
activemodel
couchrest (>= 1.0.1)
json (~> 1.6.0)
+ therubyracer
GEM
remote: http://rubygems.org/
specs:
- activemodel (3.2.1)
- activesupport (= 3.2.1)
+ activemodel (3.2.3)
+ activesupport (= 3.2.3)
builder (~> 3.0.0)
- activesupport (3.2.1)
+ activesupport (3.2.3)
i18n (~> 0.6)
multi_json (~> 1.0)
builder (3.0.0)
@@ -24,8 +25,8 @@ GEM
i18n (0.6.0)
json (1.6.5)
libv8 (3.3.10.4)
- mime-types (1.17.2)
- multi_json (1.0.4)
+ mime-types (1.18)
+ multi_json (1.0.3)
rake (0.9.2)
rest-client (1.6.7)
mime-types (>= 1.16)
@@ -49,6 +50,5 @@ DEPENDENCIES
couch_potato!
rake
rspec (>= 2.0)
- therubyracer
timecop
tzinfo
View
6 active_support_3_0.lock
@@ -5,6 +5,7 @@ PATH
activemodel
couchrest (>= 1.0.1)
json (~> 1.6.0)
+ therubyracer
GEM
remote: http://rubygems.org/
@@ -21,9 +22,9 @@ GEM
rest-client (~> 1.6.1)
diff-lcs (1.1.2)
i18n (0.5.0)
- json (1.6.5)
+ json (1.6.7)
libv8 (3.3.10.4)
- mime-types (1.17.2)
+ mime-types (1.18)
multi_json (1.0.4)
rake (0.8.7)
rest-client (1.6.7)
@@ -49,6 +50,5 @@ DEPENDENCIES
couch_potato!
rake
rspec (>= 2.0)
- therubyracer
timecop
tzinfo
View
6 active_support_3_1.lock
@@ -5,6 +5,7 @@ PATH
activemodel
couchrest (>= 1.0.1)
json (~> 1.6.0)
+ therubyracer
GEM
remote: http://rubygems.org/
@@ -24,9 +25,9 @@ GEM
rest-client (~> 1.6.1)
diff-lcs (1.1.2)
i18n (0.6.0)
- json (1.6.5)
+ json (1.6.7)
libv8 (3.3.10.4)
- mime-types (1.17.2)
+ mime-types (1.18)
multi_json (1.0.3)
rake (0.9.2)
rest-client (1.6.7)
@@ -52,6 +53,5 @@ DEPENDENCIES
couch_potato!
rake
rspec (>= 2.0)
- therubyracer
timecop
tzinfo
View
6 active_support_3_2.lock
@@ -5,6 +5,7 @@ PATH
activemodel
couchrest (>= 1.0.1)
json (~> 1.6.0)
+ therubyracer
GEM
remote: http://rubygems.org/
@@ -22,9 +23,9 @@ GEM
rest-client (~> 1.6.1)
diff-lcs (1.1.3)
i18n (0.6.0)
- json (1.6.5)
+ json (1.6.7)
libv8 (3.3.10.4)
- mime-types (1.17.2)
+ mime-types (1.18)
multi_json (1.0.4)
rake (0.9.2.2)
rest-client (1.6.7)
@@ -50,6 +51,5 @@ DEPENDENCIES
couch_potato!
rake
rspec (>= 2.0)
- therubyracer
timecop
tzinfo
View
2  couch_potato.gemspec
@@ -15,12 +15,12 @@ Gem::Specification.new do |s|
s.add_dependency 'json', '~> 1.6.0'
s.add_dependency 'couchrest', '>=1.0.1'
s.add_dependency 'activemodel'
+ s.add_dependency 'therubyracer'
s.add_development_dependency 'rspec', '>=2.0'
s.add_development_dependency 'timecop'
s.add_development_dependency 'tzinfo'
s.add_development_dependency 'rake'
- s.add_development_dependency 'therubyracer'
s.files = `git ls-files`.split("\n")
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
View
3  lib/couch_potato/database.rb
@@ -146,8 +146,7 @@ def couchrest_database
def bulk_load(ids)
response = couchrest_database.bulk_load ids
- existing_rows = response['rows'].select{|row| row.key? 'doc'}
- docs = existing_rows.map{|row| row["doc"]}
+ docs = response['rows'].map{|row| row['doc']}.compact
docs.each{|doc| doc.database = self}
end
View
8 spec/unit/database_spec.rb
@@ -73,7 +73,13 @@ class Child
let(:doc1) { DbTestUser.new }
let(:doc2) { DbTestUser.new }
let(:response) do
- {"rows" => [{}, {"doc" => doc1}, {"doc" => doc2}]}
+ {
+ "rows" => [
+ {"doc" => nil, "value" => {"rev" => "10-df5a4021129ebb70f4a111eea1e881ca", "deleted"=> true}},
+ {"doc" => doc1},
+ {"doc" => doc2}
+ ]
+ }
end
before(:each) do
Something went wrong with that request. Please try again.