Ruby client fails while iterating over view


#1

Hi There,

I’m iterating over a view like so

design_docs.All_ByID(limit: 10000, descending: true).each do |doc|
  begin
    source = source_data.get(doc.id)
    convert(source).to_json
  rescue StandardError => e
    puts "Skipped document '#{doc.id}': '#{e}'"
  end
end

But after processing some documents it fails with

/Users/christianbecker/.rbenv/versions/2.4.3/lib/ruby/gems/2.4.0/gems/couchbase-1.3.15/lib/couchbase/view_row.rb:106:in `delete': no implicit conversion of Object into String (TypeError)

This seems to be a bug. Will there be someone looking at it or do I need to migrate to libcouchbase-gem instead?

Bests
Chris


#2

I see you are using ruby 2.4.3, I haven’t tested ruby client with this version yet.


#3

Which version should I prefere? The last one mentioned on github is 2.1 which is “a little bit” outdated.


#4

Hi @christian.becker, this issue has been fixed on master (and will be released in 2.0). I have restarted maintainership of Ruby SDK, so now updates will be more frequent. To verify your code you can do the following:

git clone git://github.com/couchbase/couchbase-ruby-client.git
cd couchbase-ruby-client
bundle install
bundle exec rake compile
bundle exec rake console

And then in console:

irb(main):001:0> cb = Couchbase.connect('couchbase://127.0.0.1/beer-sample', password: 'password', username: 'Administrator')
=> #<Couchbase::Bucket:0x000055c7fd434db8 "couchbase://127.0.0.1/beer-sample/" transcoder=Couchbase::Transcoder::Document, default_flags=0x0, connected=true, timeout=2500000, bootstrap_transport=:cccp>
irb(main):002:0> cb.design_docs['beer'].brewery_beers(limit: 3, descending: true).each { |row| p cb.get(row.id) }
#<Couchbase::Result:0x000055c7fd460328 operation=:get key="zea_rotisserie_and_brewery-z_p_a_india_pale_ale" cas=1534869667137716224>
#<Couchbase::Result:0x000055c7fd47bf60 operation=:get key="zea_rotisserie_and_brewery-ponchartrain_porter" cas=1534869667110256640>
#<Couchbase::Result:0x000055c7fd47b3a8 operation=:get key="zea_rotisserie_and_brewery-lager" cas=1534869666832449536>
=> [{:key=>"[\"zea_rotisserie_and_brewery\",\"zea_rotisserie_and_brewery-z_p_a_india_pale_ale\"]", :id=>"zea_rotisserie_and_brewery-z_p_a_india_pale_ale", :value=>"null"}, {:key=>"[\"zea_rotisserie_and_brewery\",\"zea_rotisserie_and_brewery-ponchartrain_porter\"]", :id=>"zea_rotisserie_and_brewery-ponchartrain_porter", :value=>"null"}, {:key=>"[\"zea_rotisserie_and_brewery\",\"zea_rotisserie_and_brewery-lager\"]", :id=>"zea_rotisserie_and_brewery-lager", :value=>"null"}]

But also you can use :include_docs => true option to view to automatically perform Bucket#get for each id.