basho/riak-ruby-client — Issue #17: pbc client doesn't work with indexes
Author: graphex
Created: 2012-02-19 01:56:03+00:00
State: open

Whenever I try to assign an index to a RObject, it fails on store if I specify an index when the protocol is 'pbc'

```ruby
it "pbc client should work" do
#the test works with :protocol => 'http'
riak_client = Riak::Client.new(:protocol => 'pbc', :host => '127.0.0.1', :pb_port => 8081, :http_port => 8091)
testval = SecureRandom.hex(64)
riak_bucket = riak_client.bucket("test")
riak_object = riak_bucket.get_or_new("test_key")
puts riak_object.inspect
riak_object.data = {:value => testval}

#the test works without this line:
riak_object.indexes = {"test_bin" => ["myindex"]}

riak_object.store
riak_object.reload
puts riak_object.data
newval = riak_object.data["value"]
newval.should == testval
end
```

error is

```
Fast Debugger (ruby-debug-ide 0.4.17.beta8, ruby-debug-base 0.11.30.pre10) listens on 127.0.0.1:58246
#"ffe90958dcd76989bbdc86384db3ce717d720f2f3c1cad737f925b37be4ff1a362f16c85e520801df5aea162d808f2bee627bde1756c107222f794f4db20e581"}>

NoMethodError: undefinedod `<<' for nil:NilClass
.rvm/gems/ruby-1.9.3-p0@boat/gems/riak-client-1.0.0/lib/riak/client/beefcake/object_methods.rb:93:in `decode_index'
.rvm/gems/ruby-1.9.3-p0@boat/gems/riak-client-1.0.0/lib/riak/client/beefcake/object_methods.rb:61:in `block in load_content'
.rvm/gems/ruby-1.9.3-p0@boat/gems/riak-client-1.0.0/lib/riak/client/beefcake/object_methods.rb:61:in `each'
.rvm/gems/ruby-1.9.3-p0@boat/gems/riak-client-1.0.0/lib/riak/client/beefcake/object_methods.rb:61:in `load_content'
.rvm/gems/ruby-1.9.3-p0@boat/gems/riak-client-1.0.0/lib/riak/client/beefcake/object_methods.rb:44:in `load_object'
.rvm/gems/ruby-1.9.3-p0@boat/gems/riak-client-1.0.0/lib/riak/client/beefcake_protobuffs_backend.rb:159:in `decode_response'
.rvm/gems/ruby-1.9.3-p0@boat/gems/riak-client-1.0.0/lib/riak/client/beefcake_protobuffs_backend.rb:59:in `store_object'
.rvm/gems/ruby-1.9.3-p0@boat/gems/riak-client-1.0.0/lib/riak/client.rb:508:in `block in store_object'
.rvm/gems/ruby-1.9.3-p0@boat/gems/riak-client-1.0.0/lib/riak/client.rb:428:in `block in recover_from'
.rvm/gems/ruby-1.9.3-p0@boat/gems/riak-client-1.0.0/lib/riak/client/pool.rb:126:in `take'
.rvm/gems/ruby-1.9.3-p0@boat/gems/riak-client-1.0.0/lib/riak/client.rb:426:in `recover_from'
.rvm/gems/ruby-1.9.3-p0@boat/gems/riak-client-1.0.0/lib/riak/client.rb:374:in `protobuffs'
.rvm/gems/ruby-1.9.3-p0@boat/gems/riak-client-1.0.0/lib/riak/client.rb:128:in `backend'
.rvm/gems/ruby-1.9.3-p0@boat/gems/riak-client-1.0.0/lib/riak/client.rb:507:in `store_object'
.rvm/gems/ruby-1.9.3-p0@boat/gems/riak-client-1.0.0/lib/riak/robject.rb:179:in `store'
myproj/spec/models/riak_spec.rb:71:in `block (3 levels) in '
.rvm/gems/ruby-1.9.3-p0@boat/gems/rspec-core-2.8.0/lib/rspec/core/example.rb:80:in `instance_eval'
.rvm/gems/ruby-1.9.3-p0@boat/gems/rspec-core-2.8.0/lib/rspec/core/example.rb:80:in `block in run'
.rvm/gems/ruby-1.9.3-p0@boat/gems/rspec-core-2.8.0/lib/rspec/core/example.rb:173:in `with_around_hooks'
.rvm/gems/ruby-1.9.3-p0@boat/gems/rspec-core-2.8.0/lib/rspec/core/example.rb:77:in `run'
.rvm/gems/ruby-1.9.3-p0@boat/gems/rspec-core-2.8.0/lib/rspec/core/example_group.rb:355:in `block in run_examples'
.rvm/gems/ruby-1.9.3-p0@boat/gems/rspec-core-2.8.0/lib/rspec/core/example_group.rb:351:in `map'
.rvm/gems/ruby-1.9.3-p0@boat/gems/rspec-core-2.8.0/lib/rspec/core/example_group.rb:351:in `run_examples'
.rvm/gems/ruby-1.9.3-p0@boat/gems/rspec-core-2.8.0/lib/rspec/core/example_group.rb:337:in `run'
.rvm/gems/ruby-1.9.3-p0@boat/gems/rspec-core-2.8.0/lib/rspec/core/example_group.rb:338:in `block in run'
.rvm/gems/ruby-1.9.3-p0@boat/gems/rspec-core-2.8.0/lib/rspec/core/example_group.rb:338:in `map'
.rvm/gems/ruby-1.9.3-p0@boat/gems/rspec-core-2.8.0/lib/rspec/core/example_group.rb:338:in `run'
.rvm/gems/ruby-1.9.3-p0@boat/gems/rspec-core-2.8.0/lib/rspec/core/command_line.rb:28:in `block (2 levels) in run'
.rvm/gems/ruby-1.9.3-p0@boat/gems/rspec-core-2.8.0/lib/rspec/core/command_line.rb:28:in `map'
.rvm/gems/ruby-1.9.3-p0@boat/gems/rspec-core-2.8.0/lib/rspec/core/command_line.rb:28:in `block in run'
.rvm/gems/ruby-1.9.3-p0@boat/gems/rspec-core-2.8.0/lib/rspec/core/reporter.rb:34:in `report'
.rvm/gems/ruby-1.9.3-p0@boat/gems/rspec-core-2.8.0/lib/rspec/core/command_line.rb:25:in `run'
.rvm/gems/ruby-1.9.3-p0@boat/gems/rspec-core-2.8.0/lib/rspec/core/runner.rb:80:in `run_in_process'
.rvm/gems/ruby-1.9.3-p0@boat/gems/rspec-core-2.8.0/lib/rspec/core/runner.rb:69:in `run'
.rvm/gems/ruby-1.9.3-p0@boat/gems/rspec-core-2.8.0/lib/rspec/core/runner.rb:10:in `block in autorun'
.rvm/gems/ruby-1.9.3-p0@boat/gems/ruby-debug-ide-0.4.17.beta8/lib/ruby-debug-ide.rb:127:in `debug_load'
.rvm/gems/ruby-1.9.3-p0@boat/gems/ruby-debug-ide-0.4.17.beta8/lib/ruby-debug-ide.rb:127:in `debug_program'
.rvm/gems/ruby-1.9.3-p0@boat/gems/ruby-debug-ide-0.4.17.beta8/bin/rdebug-ide:95:in `'
-e:1:in `load'
-e:1:in `

'
```

My storage backend is eLevelDB and the HTTP client protocol works flawlessly.