{"action":"created","comment":{"url":"https://api.github.com/repos/cakephp/docs/pulls/comments/29988521","id":29988521,"diff_hunk":"@@ -533,6 +533,44 @@ load fields off of contained associations, you can use ``autoFields()``::\n         ->contain(['Users'])\n         ->autoFields(true);\n \n+Sometimes you want to restrict the number associated data returned by a contain. That will cause a problem\n+because the rule will be applied to the whole query by the join.\n+The solution to do that is to move the fetcher out of the main query calling the option ``strategy``. \n+That way you can apply rules such as ``limit()`` or ``order()``, to the subquery::\n+\n+    // In the example below, we have several translated comments on any articles.\n+    // the Comments table could look like as shown:\n+    | id | article_id | language_id | comment          |\n+    |  1 |          1 |           1 | French comment   |\n+    |  2 |          1 |           3 | Spanish comment  |\n+    |  3 |          1 |           9 | English comment  |\n+    |  4 |          2 |           1 | French comment   |\n+    |  5 |          2 |           9 | English comment  |\n+    \n+    // What we want to do here is to return the comment in Spanish if it exists, if not, in English, if not, in French\n+    $languageFr_id = 1;\n+    $languageEn_id = 9;\n+    $reqLanguage_id = $this->request->datas['reqLanguageId']; // for example\n+","path":"en/orm/retrieving-data-and-resultsets.rst","position":22,"original_position":22,"commit_id":"154a5c08fae5ff2796cf2d62021b07a55205f695","original_commit_id":"154a5c08fae5ff2796cf2d62021b07a55205f695","user":{"login":"markstory","id":24086,"avatar_url":"https://avatars.githubusercontent.com/u/24086?v=3","gravatar_id":"","url":"https://api.github.com/users/markstory","html_url":"https://github.com/markstory","followers_url":"https://api.github.com/users/markstory/followers","following_url":"https://api.github.com/users/markstory/following{/other_user}","gists_url":"https://api.github.com/users/markstory/gists{/gist_id}","starred_url":"https://api.github.com/users/markstory/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/markstory/subscriptions","organizations_url":"https://api.github.com/users/markstory/orgs","repos_url":"https://api.github.com/users/markstory/repos","events_url":"https://api.github.com/users/markstory/events{/privacy}","received_events_url":"https://api.github.com/users/markstory/received_events","type":"User","site_admin":false},"body":"Should be camelBacked.","created_at":"2015-05-09T02:12:43Z","updated_at":"2015-05-09T02:12:43Z","html_url":"https://github.com/cakephp/docs/pull/2710#discussion_r29988521","pull_request_url":"https://api.github.com/repos/cakephp/docs/pulls/2710","_links":{"self":{"href":"https://api.github.com/repos/cakephp/docs/pulls/comments/29988521"},"html":{"href":"https://github.com/cakephp/docs/pull/2710#discussion_r29988521"},"pull_request":{"href":"https://api.github.com/repos/cakephp/docs/pulls/2710"}}},"pull_request":{"url":"https://api.github.com/repos/cakephp/docs/pulls/2710","id":34995369,"html_url":"https://github.com/cakephp/docs/pull/2710","diff_url":"https://github.com/cakephp/docs/pull/2710.diff","patch_url":"https://github.com/cakephp/docs/pull/2710.patch","issue_url":"https://api.github.com/repos/cakephp/docs/issues/2710","number":2710,"state":"open","locked":false,"title":"Update retrieving-data-and-resultsets.rst","user":{"login":"caBBAlainB","id":9322571,"avatar_url":"https://avatars.githubusercontent.com/u/9322571?v=3","gravatar_id":"","url":"https://api.github.com/users/caBBAlainB","html_url":"https://github.com/caBBAlainB","followers_url":"https://api.github.com/users/caBBAlainB/followers","following_url":"https://api.github.com/users/caBBAlainB/following{/other_user}","gists_url":"https://api.github.com/users/caBBAlainB/gists{/gist_id}","starred_url":"https://api.github.com/users/caBBAlainB/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/caBBAlainB/subscriptions","organizations_url":"https://api.github.com/users/caBBAlainB/orgs","repos_url":"https://api.github.com/users/caBBAlainB/repos","events_url":"https://api.github.com/users/caBBAlainB/events{/privacy}","received_events_url":"https://api.github.com/users/caBBAlainB/received_events","type":"User","site_admin":false},"body":"Add an explanation and an example about the contain's option 'strategy'.","created_at":"2015-05-08T10:00:32Z","updated_at":"2015-05-09T02:12:44Z","closed_at":null,"merged_at":null,"merge_commit_sha":"fdf90f57750bdd3e7c773fbe7896c281edfe5eff","assignee":null,"milestone":{"url":"https://api.github.com/repos/cakephp/docs/milestones/1","html_url":"https://github.com/cakephp/docs/milestones/3.0","labels_url":"https://api.github.com/repos/cakephp/docs/milestones/1/labels","id":629438,"number":1,"title":"3.0","description":"","creator":{"login":"markstory","id":24086,"avatar_url":"https://avatars.githubusercontent.com/u/24086?v=3","gravatar_id":"","url":"https://api.github.com/users/markstory","html_url":"https://github.com/markstory","followers_url":"https://api.github.com/users/markstory/followers","following_url":"https://api.github.com/users/markstory/following{/other_user}","gists_url":"https://api.github.com/users/markstory/gists{/gist_id}","starred_url":"https://api.github.com/users/markstory/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/markstory/subscriptions","organizations_url":"https://api.github.com/users/markstory/orgs","repos_url":"https://api.github.com/users/markstory/repos","events_url":"https://api.github.com/users/markstory/events{/privacy}","received_events_url":"https://api.github.com/users/markstory/received_events","type":"User","site_admin":false},"open_issues":12,"closed_issues":877,"state":"open","created_at":"2014-04-14T15:44:13Z","updated_at":"2015-05-09T02:11:31Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/cakephp/docs/pulls/2710/commits","review_comments_url":"https://api.github.com/repos/cakephp/docs/pulls/2710/comments","review_comment_url":"https://api.github.com/repos/cakephp/docs/pulls/comments{/number}","comments_url":"https://api.github.com/repos/cakephp/docs/issues/2710/comments","statuses_url":"https://api.github.com/repos/cakephp/docs/statuses/154a5c08fae5ff2796cf2d62021b07a55205f695","head":{"label":"caBBAlainB:patch-42","ref":"patch-42","sha":"154a5c08fae5ff2796cf2d62021b07a55205f695","user":{"login":"caBBAlainB","id":9322571,"avatar_url":"https://avatars.githubusercontent.com/u/9322571?v=3","gravatar_id":"","url":"https://api.github.com/users/caBBAlainB","html_url":"https://github.com/caBBAlainB","followers_url":"https://api.github.com/users/caBBAlainB/followers","following_url":"https://api.github.com/users/caBBAlainB/following{/other_user}","gists_url":"https://api.github.com/users/caBBAlainB/gists{/gist_id}","starred_url":"https://api.github.com/users/caBBAlainB/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/caBBAlainB/subscriptions","organizations_url":"https://api.github.com/users/caBBAlainB/orgs","repos_url":"https://api.github.com/users/caBBAlainB/repos","events_url":"https://api.github.com/users/caBBAlainB/events{/privacy}","received_events_url":"https://api.github.com/users/caBBAlainB/received_events","type":"User","site_admin":false},"repo":{"id":26536837,"name":"docs","full_name":"caBBAlainB/docs","owner":{"login":"caBBAlainB","id":9322571,"avatar_url":"https://avatars.githubusercontent.com/u/9322571?v=3","gravatar_id":"","url":"https://api.github.com/users/caBBAlainB","html_url":"https://github.com/caBBAlainB","followers_url":"https://api.github.com/users/caBBAlainB/followers","following_url":"https://api.github.com/users/caBBAlainB/following{/other_user}","gists_url":"https://api.github.com/users/caBBAlainB/gists{/gist_id}","starred_url":"https://api.github.com/users/caBBAlainB/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/caBBAlainB/subscriptions","organizations_url":"https://api.github.com/users/caBBAlainB/orgs","repos_url":"https://api.github.com/users/caBBAlainB/repos","events_url":"https://api.github.com/users/caBBAlainB/events{/privacy}","received_events_url":"https://api.github.com/users/caBBAlainB/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/caBBAlainB/docs","description":"CakePHP CookBook","fork":true,"url":"https://api.github.com/repos/caBBAlainB/docs","forks_url":"https://api.github.com/repos/caBBAlainB/docs/forks","keys_url":"https://api.github.com/repos/caBBAlainB/docs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/caBBAlainB/docs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/caBBAlainB/docs/teams","hooks_url":"https://api.github.com/repos/caBBAlainB/docs/hooks","issue_events_url":"https://api.github.com/repos/caBBAlainB/docs/issues/events{/number}","events_url":"https://api.github.com/repos/caBBAlainB/docs/events","assignees_url":"https://api.github.com/repos/caBBAlainB/docs/assignees{/user}","branches_url":"https://api.github.com/repos/caBBAlainB/docs/branches{/branch}","tags_url":"https://api.github.com/repos/caBBAlainB/docs/tags","blobs_url":"https://api.github.com/repos/caBBAlainB/docs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/caBBAlainB/docs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/caBBAlainB/docs/git/refs{/sha}","trees_url":"https://api.github.com/repos/caBBAlainB/docs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/caBBAlainB/docs/statuses/{sha}","languages_url":"https://api.github.com/repos/caBBAlainB/docs/languages","stargazers_url":"https://api.github.com/repos/caBBAlainB/docs/stargazers","contributors_url":"https://api.github.com/repos/caBBAlainB/docs/contributors","subscribers_url":"https://api.github.com/repos/caBBAlainB/docs/subscribers","subscription_url":"https://api.github.com/repos/caBBAlainB/docs/subscription","commits_url":"https://api.github.com/repos/caBBAlainB/docs/commits{/sha}","git_commits_url":"https://api.github.com/repos/caBBAlainB/docs/git/commits{/sha}","comments_url":"https://api.github.com/repos/caBBAlainB/docs/comments{/number}","issue_comment_url":"https://api.github.com/repos/caBBAlainB/docs/issues/comments{/number}","contents_url":"https://api.github.com/repos/caBBAlainB/docs/contents/{+path}","compare_url":"https://api.github.com/repos/caBBAlainB/docs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/caBBAlainB/docs/merges","archive_url":"https://api.github.com/repos/caBBAlainB/docs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/caBBAlainB/docs/downloads","issues_url":"https://api.github.com/repos/caBBAlainB/docs/issues{/number}","pulls_url":"https://api.github.com/repos/caBBAlainB/docs/pulls{/number}","milestones_url":"https://api.github.com/repos/caBBAlainB/docs/milestones{/number}","notifications_url":"https://api.github.com/repos/caBBAlainB/docs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/caBBAlainB/docs/labels{/name}","releases_url":"https://api.github.com/repos/caBBAlainB/docs/releases{/id}","created_at":"2014-11-12T13:21:14Z","updated_at":"2014-11-12T03:49:46Z","pushed_at":"2015-05-08T11:29:02Z","git_url":"git://github.com/caBBAlainB/docs.git","ssh_url":"git@github.com:caBBAlainB/docs.git","clone_url":"https://github.com/caBBAlainB/docs.git","svn_url":"https://github.com/caBBAlainB/docs","homepage":"http://book.cakephp.org","size":34221,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"cakephp:3.0","ref":"3.0","sha":"0ea13a03f434abbdab1c4a5b16c982f0a73da28f","user":{"login":"cakephp","id":23666,"avatar_url":"https://avatars.githubusercontent.com/u/23666?v=3","gravatar_id":"","url":"https://api.github.com/users/cakephp","html_url":"https://github.com/cakephp","followers_url":"https://api.github.com/users/cakephp/followers","following_url":"https://api.github.com/users/cakephp/following{/other_user}","gists_url":"https://api.github.com/users/cakephp/gists{/gist_id}","starred_url":"https://api.github.com/users/cakephp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cakephp/subscriptions","organizations_url":"https://api.github.com/users/cakephp/orgs","repos_url":"https://api.github.com/users/cakephp/repos","events_url":"https://api.github.com/users/cakephp/events{/privacy}","received_events_url":"https://api.github.com/users/cakephp/received_events","type":"Organization","site_admin":false},"repo":{"id":1514950,"name":"docs","full_name":"cakephp/docs","owner":{"login":"cakephp","id":23666,"avatar_url":"https://avatars.githubusercontent.com/u/23666?v=3","gravatar_id":"","url":"https://api.github.com/users/cakephp","html_url":"https://github.com/cakephp","followers_url":"https://api.github.com/users/cakephp/followers","following_url":"https://api.github.com/users/cakephp/following{/other_user}","gists_url":"https://api.github.com/users/cakephp/gists{/gist_id}","starred_url":"https://api.github.com/users/cakephp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cakephp/subscriptions","organizations_url":"https://api.github.com/users/cakephp/orgs","repos_url":"https://api.github.com/users/cakephp/repos","events_url":"https://api.github.com/users/cakephp/events{/privacy}","received_events_url":"https://api.github.com/users/cakephp/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/cakephp/docs","description":"CakePHP CookBook","fork":false,"url":"https://api.github.com/repos/cakephp/docs","forks_url":"https://api.github.com/repos/cakephp/docs/forks","keys_url":"https://api.github.com/repos/cakephp/docs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cakephp/docs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cakephp/docs/teams","hooks_url":"https://api.github.com/repos/cakephp/docs/hooks","issue_events_url":"https://api.github.com/repos/cakephp/docs/issues/events{/number}","events_url":"https://api.github.com/repos/cakephp/docs/events","assignees_url":"https://api.github.com/repos/cakephp/docs/assignees{/user}","branches_url":"https://api.github.com/repos/cakephp/docs/branches{/branch}","tags_url":"https://api.github.com/repos/cakephp/docs/tags","blobs_url":"https://api.github.com/repos/cakephp/docs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cakephp/docs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cakephp/docs/git/refs{/sha}","trees_url":"https://api.github.com/repos/cakephp/docs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cakephp/docs/statuses/{sha}","languages_url":"https://api.github.com/repos/cakephp/docs/languages","stargazers_url":"https://api.github.com/repos/cakephp/docs/stargazers","contributors_url":"https://api.github.com/repos/cakephp/docs/contributors","subscribers_url":"https://api.github.com/repos/cakephp/docs/subscribers","subscription_url":"https://api.github.com/repos/cakephp/docs/subscription","commits_url":"https://api.github.com/repos/cakephp/docs/commits{/sha}","git_commits_url":"https://api.github.com/repos/cakephp/docs/git/commits{/sha}","comments_url":"https://api.github.com/repos/cakephp/docs/comments{/number}","issue_comment_url":"https://api.github.com/repos/cakephp/docs/issues/comments{/number}","contents_url":"https://api.github.com/repos/cakephp/docs/contents/{+path}","compare_url":"https://api.github.com/repos/cakephp/docs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cakephp/docs/merges","archive_url":"https://api.github.com/repos/cakephp/docs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cakephp/docs/downloads","issues_url":"https://api.github.com/repos/cakephp/docs/issues{/number}","pulls_url":"https://api.github.com/repos/cakephp/docs/pulls{/number}","milestones_url":"https://api.github.com/repos/cakephp/docs/milestones{/number}","notifications_url":"https://api.github.com/repos/cakephp/docs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cakephp/docs/labels{/name}","releases_url":"https://api.github.com/repos/cakephp/docs/releases{/id}","created_at":"2011-03-23T04:54:13Z","updated_at":"2015-05-08T18:20:32Z","pushed_at":"2015-05-08T21:56:56Z","git_url":"git://github.com/cakephp/docs.git","ssh_url":"git@github.com:cakephp/docs.git","clone_url":"https://github.com/cakephp/docs.git","svn_url":"https://github.com/cakephp/docs","homepage":"http://book.cakephp.org","size":55918,"stargazers_count":462,"watchers_count":462,"language":"Makefile","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1306,"mirror_url":null,"open_issues_count":24,"forks":1306,"open_issues":24,"watchers":462,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/cakephp/docs/pulls/2710"},"html":{"href":"https://github.com/cakephp/docs/pull/2710"},"issue":{"href":"https://api.github.com/repos/cakephp/docs/issues/2710"},"comments":{"href":"https://api.github.com/repos/cakephp/docs/issues/2710/comments"},"review_comments":{"href":"https://api.github.com/repos/cakephp/docs/pulls/2710/comments"},"review_comment":{"href":"https://api.github.com/repos/cakephp/docs/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/cakephp/docs/pulls/2710/commits"},"statuses":{"href":"https://api.github.com/repos/cakephp/docs/statuses/154a5c08fae5ff2796cf2d62021b07a55205f695"}}}}