Ted, There is a simple fix for this (which I believed was in there already). First of all, install the json or yajl-ruby gems (the default parsing from ActiveSupport is bad). Then add this to your script:
ActiveSupport.parse_json_times = false ActiveSupport tries to be smart about parsing strings that look like dates or times into Date/Time objects. I've found it to be a nuisance, especially in use-cases like the one you have. Sean Cribbs <[email protected]> Developer Advocate Basho Technologies, Inc. http://basho.com/ On Oct 23, 2010, at 6:51 PM, Ted Behling wrote: > Hi, > > I am new to Riak but am starting to get familiar with it. I've been going > through the "Riak Fast Track" tutorial, and am using the riak-client Ruby > gem. Sadly, I think I have found some broken behavior in the Ruby client. > I'm hoping maybe the maintainer of the riak-client gem can help? > > The issue is that if my Riak keys look like "dates", such as "2010-01-01", > then if I invoke the "keys" method on a Riak::Bucket object, I get an error. > Non-date-looking keys work fine. > > Here are some commands that reproduce the problem, from an OS X command line: > > --------- > # This successfully creates a new bucket called "broken" and assigns a value > to the key "2010-01-01" > $ curl -X PUT -d '{"bar":"baz"}' -H "Content-Type: application/json" > http://127.0.0.1:8098/riak/broken/2010-01-01 > > # I can successfully retrieve the specific key using a Ruby one-liner > $ ruby -e "require 'rubygems'; require 'riak'; puts > Riak::Client.new.bucket('broken')['2010-01-01'].data.inspect" > curb library not found! Please `gem install curb` for better performance. > {"bar"=>"baz"} > > # A Ruby exception results when I list the keys. Note where it's trying to > invoke "tr" on a Date object, shown here formatted as a different string than > the Riak key > $ ruby -e "require 'rubygems'; require 'riak'; puts > Riak::Client.new.bucket('broken').keys" > curb library not found! Please `gem install curb` for better performance. > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/cgi.rb:352:in > `unescape': undefined method `tr' for Fri, 01 Jan 2010:Date (NoMethodError) > from > /Library/Ruby/Gems/1.8/gems/riak-client-0.8.2/lib/riak/bucket.rb:48:in `load' > from > /Library/Ruby/Gems/1.8/gems/riak-client-0.8.2/lib/riak/bucket.rb:48:in `map' > from > /Library/Ruby/Gems/1.8/gems/riak-client-0.8.2/lib/riak/bucket.rb:48:in `load' > from > /Library/Ruby/Gems/1.8/gems/riak-client-0.8.2/lib/riak/bucket.rb:69:in `keys' > from -e:1 > --------- > > Clearly, something here is trying to be "helpful" by translating the string > "2010-01-01" to a Date object. This is the wrong behavior, because Riak keys > are strings and should always be strings. Correct behavior would be to not > interpret "date-looking" or other "special appearance" strings, and just > treat all key strings literally. > > Here are the relevant software versions I am running: > Mac OS X 10.6 > riak-0.13.0-osx-i386 (downloaded from Basho) > ruby 1.8.7 (2009-06-12 patchlevel 174) [universal-darwin10.0] > Rubygems version 1.3.7 > riak-client gem, 0.8.2, installed with "gem install riak-client" > activesupport gem, 2.3.8 > > I hope someone can fix this issue. If I can contribute a patch, or you would > like me to help test a patch, please let me know what's needed. > > Best regards, > > Ted Behling > RHCE, Network+ > [email protected] > _______________________________________________ > riak-users mailing list > [email protected] > http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com _______________________________________________ riak-users mailing list [email protected] http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com
