{"action":"created","issue":{"url":"https://api.github.com/repos/cakephp/cakephp/issues/6783","labels_url":"https://api.github.com/repos/cakephp/cakephp/issues/6783/labels{/name}","comments_url":"https://api.github.com/repos/cakephp/cakephp/issues/6783/comments","events_url":"https://api.github.com/repos/cakephp/cakephp/issues/6783/events","html_url":"https://github.com/cakephp/cakephp/issues/6783","id":87304410,"number":6783,"title":"Association Alias vs. className","user":{"login":"grossrucker","id":11352929,"avatar_url":"https://avatars.githubusercontent.com/u/11352929?v=3","gravatar_id":"","url":"https://api.github.com/users/grossrucker","html_url":"https://github.com/grossrucker","followers_url":"https://api.github.com/users/grossrucker/followers","following_url":"https://api.github.com/users/grossrucker/following{/other_user}","gists_url":"https://api.github.com/users/grossrucker/gists{/gist_id}","starred_url":"https://api.github.com/users/grossrucker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/grossrucker/subscriptions","organizations_url":"https://api.github.com/users/grossrucker/orgs","repos_url":"https://api.github.com/users/grossrucker/repos","events_url":"https://api.github.com/users/grossrucker/events{/privacy}","received_events_url":"https://api.github.com/users/grossrucker/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/cakephp/cakephp/labels/On%20hold","name":"On hold","color":"eb6420"}],"state":"closed","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/cakephp/cakephp/milestones/43","html_url":"https://github.com/cakephp/cakephp/milestones/3.0.7","labels_url":"https://api.github.com/repos/cakephp/cakephp/milestones/43/labels","id":1138294,"number":43,"title":"3.0.7","description":"Bugfixes and optimizations for 3.0.x","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":16,"closed_issues":85,"state":"open","created_at":"2015-05-28T15:24:54Z","updated_at":"2015-06-11T16:14:39Z","due_on":"2015-06-13T04:00:00Z","closed_at":null},"comments":7,"created_at":"2015-06-11T11:04:08Z","updated_at":"2015-06-11T16:14:39Z","closed_at":"2015-06-11T16:14:39Z","body":"I am trying to setup a multiple belongsTo association on the same table. one table contains api keys and the second contains privileges assigned by one api key to a second api key:\r\n\r\nextract from my tables:\r\n\r\ntable:api_keys\r\nINT id (primary key)\r\nVARCHAR api_key_str\r\n\r\ntable:privileges\r\nINT id (primary key)\r\nINT owner_api_key_id (foreign key api_keys:id)\r\nINT target_api_key_id (foreign key api_keys:id)\r\nTEXT data\r\n\r\nNext I defined the two association inside the privileges table:\r\n$this->belongsTo('OwnerApiKeys', [\r\n            'className' => 'ApiKeys',\r\n            'foreignKey' => 'owner_api_key_id',\r\n            'joinType' => 'INNER'\r\n]);\r\n$this->belongsTo('TargetApiKeys', [\r\n            'className' => 'ApiKeys',\r\n            'foreignKey' => 'target_api_key_id',\r\n            'joinType' => 'INNER'\r\n]);\r\n\r\nBaking the controller and templates worked fine. I can now open the privileges/add form, choose my api keys from the drop down fields and enter the data. So far, everything seems good.\r\n\r\nHowever, an error occurs when saving the new dataset. It states that there is no schema for the table. What it is supposed to do here is to get the schema of the ApiKeys table. What it really does is trying to find a schema for the not existing \"OwnerApiKeys\"/\"TargetApiKey\" Tables during the RuleChecking procedure.\r\n\r\nWorkaround: When I change the alias of both associations to \"ApiKeys\" the error does not occur. But I believe, since I indicated the corresponding className inside the \"belongsTo\" statement that there is a bug somewhere referring to the associations alias as table/class name instead of the indicated \"className\" (which, in the case where I don't specifically define the className would be ok)."},"comment":{"url":"https://api.github.com/repos/cakephp/cakephp/issues/comments/111189475","html_url":"https://github.com/cakephp/cakephp/issues/6783#issuecomment-111189475","issue_url":"https://api.github.com/repos/cakephp/cakephp/issues/6783","id":111189475,"user":{"login":"lorenzo","id":37621,"avatar_url":"https://avatars.githubusercontent.com/u/37621?v=3","gravatar_id":"","url":"https://api.github.com/users/lorenzo","html_url":"https://github.com/lorenzo","followers_url":"https://api.github.com/users/lorenzo/followers","following_url":"https://api.github.com/users/lorenzo/following{/other_user}","gists_url":"https://api.github.com/users/lorenzo/gists{/gist_id}","starred_url":"https://api.github.com/users/lorenzo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lorenzo/subscriptions","organizations_url":"https://api.github.com/users/lorenzo/orgs","repos_url":"https://api.github.com/users/lorenzo/repos","events_url":"https://api.github.com/users/lorenzo/events{/privacy}","received_events_url":"https://api.github.com/users/lorenzo/received_events","type":"User","site_admin":false},"created_at":"2015-06-11T16:14:39Z","updated_at":"2015-06-11T16:14:39Z","body":"Ok, so the issue was that you changed the alias in the `initialize()` but not in `buildRules()`. Closing as it was just an oversight."}}