Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

2.3 containable find list #769

Merged
merged 1 commit into from

2 participants

@dereuromark
Collaborator

fixes http://cakephp.lighthouseapp.com/projects/42648/tickets/852-findlist-should-support-joins

I use this fix since 1.3alpha as a core-hack - without any issues so far. would be great if I could drop that now and if it would be handled in the core behavior now :)

@markstory markstory merged commit 8e93c47 into cakephp:2.3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 13, 2012
  1. @dereuromark
This page is out of date. Refresh to see the latest.
View
2  lib/Cake/Model/Behavior/ContainableBehavior.php
@@ -171,7 +171,7 @@ public function beforeFind(Model $Model, $query) {
}
if ($this->settings[$Model->alias]['recursive']) {
- $query['recursive'] = (isset($query['recursive'])) ? $query['recursive'] : $containments['depth'];
+ $query['recursive'] = (isset($query['recursive'])) ? max($query['recursive'], $containments['depth']) : $containments['depth'];
}
$autoFields = ($this->settings[$Model->alias]['autoFields']
View
24 lib/Cake/Test/Case/Model/Behavior/ContainableBehaviorTest.php
@@ -262,6 +262,30 @@ public function testContain() {
}
/**
+ * testContainFindList method
+ *
+ * @return void
+ */
+ public function testContainFindList() {
+ $this->Article->contain('Comment.User');
+ $result = $this->Article->find('list');
+ $expected = array(
+ 1 => 'First Article',
+ 2 => 'Second Article',
+ 3 => 'Third Article'
+ );
+ $this->assertEquals($expected, $result);
+
+ $result = $this->Article->find('list', array('fields'=>array('Article.id', 'User.id'), 'contain'=>array('User')));
+ $expected = array(
+ 1 => '1',
+ 2 => '3',
+ 3 => '1'
+ );
+ $this->assertEquals($expected, $result);
+ }
+
+/**
* testFindEmbeddedNoBindings method
*
* @return void
Something went wrong with that request. Please try again.