Skip to content

Commit 7ec2ff3

Browse files
brett19avsej
authored andcommitted
PCBC-646: Fixed issue with blank string decoding.
Change-Id: I8ae2ed85b16450ba818af359b31e6714827d19a8 Reviewed-on: http://review.couchbase.org/117410 Tested-by: Build Bot <[email protected]> Reviewed-by: Sergey Avseyev <[email protected]>
1 parent dbfa1fb commit 7ec2ff3

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

src/couchbase/document.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ void pcbc_document_init_decode(zval *return_value, pcbc_bucket_t *bucket, const
4242
{
4343
object_init_ex(return_value, pcbc_document_ce);
4444

45-
if (bytes_len) {
45+
{
4646
PCBC_ZVAL val;
4747
PCBC_ZVAL_ALLOC(val);
4848
pcbc_decode_value(PCBC_P(val), bucket, bytes, bytes_len, flags, datatype TSRMLS_CC);

tests/BucketTest.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,36 @@ function testBasicRemove($b, $key) {
9292
}, '\Couchbase\Exception', COUCHBASE_KEYNOTFOUND);
9393
}
9494

95+
/**
96+
* Test blank string storage and retrieval
97+
*
98+
* @depends testConnect
99+
*/
100+
function testBlankStringTrans($b) {
101+
$key = $this->makeKey('blankStringTrans');
102+
103+
$res = $b->upsert($key, '');
104+
$this->assertValidMetaDoc($res, 'cas');
105+
106+
$res = $b->get($key);
107+
$this->assertValidMetaDoc($res, 'cas', 'flags');
108+
$this->assertEquals($res->value, '');
109+
}
110+
111+
/**
112+
* Test handing NULL values
113+
*
114+
* @depends testConnect
115+
*/
116+
function testEmptyNullValues($b) {
117+
$key = $this->makeKey('nullValue');
118+
$res = $b->upsert($key, null);
119+
$this->assertValidMetaDoc($res, 'cas');
120+
$res = $b->get($key);
121+
$this->assertValidMetaDoc($res, 'cas', 'flags');
122+
$this->assertEquals(null, $res->value);
123+
}
124+
95125
/**
96126
* Test multi upsert
97127
*

0 commit comments

Comments
 (0)