Create a gist now

Instantly share code, notes, and snippets.

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)
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
@ingenthr

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.

@avsej

Replied in RCBC-112

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment