Skip to content

Instantly share code, notes, and snippets.

@scalabl3
Last active December 11, 2015 08:38
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save scalabl3/6c1762696ff5fe769a78 to your computer and use it in GitHub Desktop.
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
Copy link

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
Copy link

avsej commented Jan 22, 2013

Replied in RCBC-112

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