/gist:6c1762696ff5fe769a78 Secret
Last active
December 11, 2015 08:38
Star
You must be signed in to star a gist
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)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.