Details
Description
When storing strings using the `set` command and using `append` to append another string to it results in a ValueFormatError. It appears that string values are actually converted to JSON instead of just being stored as strings. The result being that the appended string is appended after quotation marks. Adding "baz" to "bar" results in "bar"baz in CB and is now unserializable.
I understand why the error is thrown, and I would expect it from JSON serialized objects, but not from standard strings. Other memcached libraries, and the previous version of the python CB client, worked appropriately. Of course, the code workaround is to use format=couchbase.FMT_BYTES on the set command, but this shouldn't be necessary when flags are already used when storing an object to determine the format. If it is a python string, then mark it as such in the flags, but adding additional escaping breaks other commands that should "just work", especially when wanting to make switching to CB easier.
Example:
Python 2.7.3 (default, Aug 1 2012, 05:14:39)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import couchbase
>>> c = couchbase.Couchbase.connect(bucket='default', host='192.168.56.70')
>>> c.set("foo", "bar")
OperationResult<RC=0x0, Key=foo, CAS=0x8bac42ea89010000>
>>> c.append("foo", "baz")
OperationResult<RC=0x0, Key=foo, CAS=0x3ae494c68b010000>
>>> c.get("foo")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/opt/[redacted]/usr/local/lib/python2.7/site-packages/couchbase/connection.py", line 325, in get
return _Base.get(self, key, ttl, quiet)
File "/usr/lib/python2.7/json/_init_.py", line 326, in loads
return _default_decoder.decode(s)
File "/usr/lib/python2.7/json/decoder.py", line 369, in decode
raise ValueError(errmsg("Extra data", s, end, len(s)))
couchbase.exceptions.ValueFormatError: <Failed to decode bytes, Results=1, inner_cause=Extra data: line 1 column 5 - line 1 column 8
(char 5 - 8), C Source=(src/convert.c,215), OBJ='"bar"baz'>
>>>