Description
When passing a non-string as the key to any CRUD operation (insert, upsert or get) the return value is
array(0) { }
|
This seems incorrect to me, there should be some sort of error returned within a CouchbaseMetaDoc, which is the expected output which specifies why the operation failed.
Alternatively, if a string must be used for the key, then the SDK should try and convert the value passed to it to a string before performing the operation.
Example code to reproduce:
<?php
|
|
$cluster = new CouchbaseCluster('http://localhost:8091');
|
$bucket = $cluster->openBucket('default');
|
for ($i = 1; $i <= 10000; $i++) {
|
$result = $bucket->upsert($i, '');
|
var_dump($result);
|
}
|
This returns 10000 of the following:
array(0) {
|
}
|
When the key is converted to a string before being passed to the SDK, there is no issue.
Example:
<?php
|
|
$cluster = new CouchbaseCluster('http://localhost:8091');
|
$bucket = $cluster->openBucket('default');
|
for ($i = 1; $i <= 10000; $i++) {
|
$result = $bucket->upsert("$i", '');
|
var_dump($result);
|
}
|
Output:
object(CouchbaseMetaDoc)#4 (4) {
|
["error"]=>
|
NULL
|
["value"]=>
|
string(0) ""
|
["flags"]=>
|
int(0)
|
["cas"]=>
|
resource(10002) of type (CouchbaseCAS)
|
}
|
Attachments
Issue Links
- is duplicated by
-
PCBC-364 Passing empty string as key returns NULL
- Resolved