Permalink
Browse files

read function "include_docs" now only applies for non-view

  • Loading branch information...
maxwellium committed May 4, 2012
1 parent 09d3627 commit 4af8a034bdfd9f76519ccd219318c94704cd69f6
Showing with 16 additions and 5 deletions.
  1. +16 −5 Model/Datasource/CouchDBSource.php
@@ -495,6 +495,14 @@ public function read(Model $model, $queryData = array(), $recursive = null) {
$url .= '_design/' . $queryData['design'] . '/_view/' . $queryData['view'];
} elseif(isset($queryData['conditions'][$model->alias . '.' . $model->primaryKey])) {
$url .= $queryData['conditions'][$model->alias . '.' . $model->primaryKey];
+
+ if ($queryData['fields'] == 'count') {
+ if (isset($queryData['params']['limit'])) {
+ unset($queryData['params']['limit']);
+ }
+ } else {
+ $params['include_docs'] = 'true';
+ }
} else {
$url .= '_all_docs';
if (!empty($queryData['limit'])) {
@@ -507,14 +515,17 @@ public function read(Model $model, $queryData = array(), $recursive = null) {
// FIXME: ? increase skip value for real pagination with page jumping? page * 10 e.g.?
}
}
- }
- if ($queryData['fields'] == 'count') {
- unset($queryData['params']['limit']);
- } else {
- $params['include_docs'] = 'true';
+ if ($queryData['fields'] == 'count') {
+ if (isset($queryData['params']['limit'])) {
+ unset($queryData['params']['limit']);
+ }
+ } else {
+ $params['include_docs'] = 'true';
+ }
}
+
if (isset($queryData['params']) && is_array($queryData['params'])) {
foreach ($queryData['params'] as $parameter => $value) {
$params[$parameter] = json_encode($value);

0 comments on commit 4af8a03

Please sign in to comment.