secret
Last active

Append/Prepend error/bug in Ruby Gem, adding a " (double quote) character on each append, sometimes more than one, unless :format => :plain is used on every operation (but that should be the default)

  • Download Gist
gistfile1.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
cb = Couchbase.connect
 
cb.set("mylist", "oranges", :format => :plain)
 
puts cb.get("mylist").to_s
# => oranges
 
cb.prepend("mylist", "apples,")
 
puts cb.get("mylist").to_s
# => "apples,"oranges
 
cb.append("mylist", ",bananas")
 
puts cb.get("mylist").to_s
# => "apples,"oranges",bananas"
 
cb.append("mylist", ",lemons")
 
puts cb.get("mylist").to_s
# => "apples,"oranges",bananas"",lemons"
 
cb.append("mylist", ",grapes")
 
puts cb.get("mylist").to_s
# => "apples,"oranges",bananas"",lemons"",grapes"
 
 
 
cb = Couchbase.connect
 
cb.set("mylist", "oranges", :format => :plain)
 
puts cb.get("mylist").to_s
# => oranges
 
cb.prepend("mylist", "apples,", :format => :plain)
 
puts cb.get("mylist").to_s
# => apples,oranges
 
cb.append("mylist", ",bananas", :format => :plain)
 
puts cb.get("mylist").to_s
# => apples,oranges,bananas
 
cb.append("mylist", ",lemons", :format => :plain)
 
puts cb.get("mylist").to_s
# => apples,oranges,bananas,lemons
 
cb.append("mylist", ",grapes", :format => :plain)
 
puts cb.get("mylist").to_s
# => apples,oranges,bananas,lemons,grapes

I think in this case you want to set the format on the connection. The challenge here is that Ruby doesn't keep track of the underlying datatype. I'm sure Sergey will have more to say.

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.