Permalink
Browse files

Fix for couchdb update when rev is missing.

  • Loading branch information...
1 parent b10bb30 commit 7c7832bcef1a10b991f69fe22ddf9d1ed8076010 @gwoo gwoo committed Jan 19, 2013
Showing with 5 additions and 7 deletions.
  1. +5 −7 data/source/http/adapter/CouchDb.php
@@ -236,7 +236,8 @@ public function read($query, array $options = array()) {
}
$path = "{$config['database']}/{$_path}";
$args = (array) $conditions + (array) $limit + (array) $order;
- $result = (array) json_decode($conn->get($path, $args), true);
+ $result = $conn->get($path, $args);
+ $result = is_string($result) ? json_decode($result, true) : $result;
$data = $stats = array();
if (isset($result['_id'])) {
@@ -488,13 +489,10 @@ public static function enabled($feature = null) {
* @return array
*/
protected function _format(array $data) {
- if (isset($data['_id'])) {
- $data['id'] = $data['_id'];
- }
- if (isset($data['_rev'])) {
- $data['rev'] = $data['_rev'];
+ foreach (array("id", "rev") as $key) {
+ $data[$key] = isset($data["_{$key}"]) ? $data["_{$key}"] : null;
+ unset($data["_{$key}"]);
}
- unset($data['_id'], $data['_rev']);
return $data;
}
}

0 comments on commit 7c7832b

Please sign in to comment.