{"action":"created","issue":{"url":"https://api.github.com/repos/yiisoft/yii/issues/176","labels_url":"https://api.github.com/repos/yiisoft/yii/issues/176/labels{/name}","comments_url":"https://api.github.com/repos/yiisoft/yii/issues/176/comments","events_url":"https://api.github.com/repos/yiisoft/yii/issues/176/events","html_url":"https://github.com/yiisoft/yii/issues/176","id":3239495,"number":176,"title":"Active Record foreach error in relations when no primary key defined","user":{"login":"qiangxue","id":993322,"avatar_url":"https://avatars.githubusercontent.com/u/993322?v=3","gravatar_id":"","url":"https://api.github.com/users/qiangxue","html_url":"https://github.com/qiangxue","followers_url":"https://api.github.com/users/qiangxue/followers","following_url":"https://api.github.com/users/qiangxue/following{/other_user}","gists_url":"https://api.github.com/users/qiangxue/gists{/gist_id}","starred_url":"https://api.github.com/users/qiangxue/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/qiangxue/subscriptions","organizations_url":"https://api.github.com/users/qiangxue/orgs","repos_url":"https://api.github.com/users/qiangxue/repos","events_url":"https://api.github.com/users/qiangxue/events{/privacy}","received_events_url":"https://api.github.com/users/qiangxue/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":8,"created_at":"2012-02-15T18:46:54Z","updated_at":"2015-07-18T09:03:20Z","closed_at":"2014-02-26T13:05:22Z","body":"<b>What steps will reproduce the problem?</b>\n1.create table with no primary key\n2.create a relation to from that table to another (with or without primary key)\n3.attempt to use it\n\n<b>What is the expected output? What do you see instead?</b>\njoin on the specified FK or array('t1.column'=&gt;'t2.column')\n\n<b>What version of the product are you using? On what operating system?</b>\nr3484 on linux\n\n<b>Please provide any additional information below.</b>\nIn CActiveFinder Line 481 defaults to an array of primary keys if the primary key in the schema isn't a string, causing the foreach error. \n\nReplacing this line with &quot;elseif (is_array($this-&gt;_table-&gt;primaryKey))&quot; allows it to skip over the PK storage and continue. This is not completely tested but fixed my specific problem, I'm not versed enough in active record to suggest it as an immediate fix before someone can look it over. :)<p>Migrated from http://code.google.com/p/yii/issues/detail?id=3023</p><hr/><h2>earlier comments</h2>\n<p><strong>paystey2k5 said, at 2011-12-14T15:55:45.000Z:</strong></p>\n<p>I should explain that when joining the relation simply providing a one column FK obviously won't work in HAS_ONE as it needs the foreign table column to equal the base tables primary key. But the BELONGS_TO should work with only a primary key as should specifying an array of column=>column values.</p><p><strong>qiang.xue said, at 2012-01-01T03:36:55.000Z:</strong></p>\n<p>set for 1.1.10 milestone</p><p><strong>paystey2k5 said, at 2012-01-13T13:24:44.000Z:</strong></p>\n<p>Here's my current fix attached</p>"},"comment":{"url":"https://api.github.com/repos/yiisoft/yii/issues/comments/122515489","html_url":"https://github.com/yiisoft/yii/issues/176#issuecomment-122515489","issue_url":"https://api.github.com/repos/yiisoft/yii/issues/176","id":122515489,"user":{"login":"johnss","id":2218593,"avatar_url":"https://avatars.githubusercontent.com/u/2218593?v=3","gravatar_id":"","url":"https://api.github.com/users/johnss","html_url":"https://github.com/johnss","followers_url":"https://api.github.com/users/johnss/followers","following_url":"https://api.github.com/users/johnss/following{/other_user}","gists_url":"https://api.github.com/users/johnss/gists{/gist_id}","starred_url":"https://api.github.com/users/johnss/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/johnss/subscriptions","organizations_url":"https://api.github.com/users/johnss/orgs","repos_url":"https://api.github.com/users/johnss/repos","events_url":"https://api.github.com/users/johnss/events{/privacy}","received_events_url":"https://api.github.com/users/johnss/received_events","type":"User","site_admin":false},"created_at":"2015-07-18T09:03:20Z","updated_at":"2015-07-18T09:03:20Z","body":"I'm still dont know why yii not throwing an exception, it will make it the programmer know what is wrong, the error is in the sql schema not in CActiveFinder.\r\n\r\nit takes me lot of time to know the error, is there any reason for not throwing exception ?"}}