Removed overriding of recursive to 0 in Model::_findNeighbors() if 'recusive' option is not specified in find options. Closes #860

This commit is contained in:
ADmad 2011-01-30 04:13:01 +05:30
parent 01801a7777
commit 88d5db76fd
2 changed files with 14 additions and 10 deletions

View file

@ -2321,7 +2321,6 @@ class Model extends Object {
*/ */
protected function _findNeighbors($state, $query, $results = array()) { protected function _findNeighbors($state, $query, $results = array()) {
if ($state == 'before') { if ($state == 'before') {
$query = array_merge(array('recursive' => 0), $query);
extract($query); extract($query);
$conditions = (array)$conditions; $conditions = (array)$conditions;
if (isset($field) && isset($value)) { if (isset($field) && isset($value)) {

View file

@ -3504,11 +3504,14 @@ class ModelReadTest extends BaseModelTest {
$expected = array( $expected = array(
'prev' => null, 'prev' => null,
'next' => array( 'next' => array(
'Article' => array('id' => 2) 'Article' => array('id' => 2),
'Comment' => array(),
'Tag' => array()
)); ));
$this->assertEqual($result, $expected); $this->assertEqual($result, $expected);
$TestModel->id = 2; $TestModel->id = 2;
$TestModel->recursive = 0;
$result = $TestModel->find('neighbors', array( $result = $TestModel->find('neighbors', array(
'fields' => array('id') 'fields' => array('id')
)); ));
@ -3525,12 +3528,14 @@ class ModelReadTest extends BaseModelTest {
$this->assertEqual($result, $expected); $this->assertEqual($result, $expected);
$TestModel->id = 3; $TestModel->id = 3;
$TestModel->recursive = 1;
$result = $TestModel->find('neighbors', array('fields' => array('id'))); $result = $TestModel->find('neighbors', array('fields' => array('id')));
$expected = array( $expected = array(
'prev' => array( 'prev' => array(
'Article' => array( 'Article' => array('id' => 2),
'id' => 2 'Comment' => array(),
)), 'Tag' => array()
),
'next' => null 'next' => null
); );
$this->assertEqual($result, $expected); $this->assertEqual($result, $expected);