{"action":"created","issue":{"url":"https://api.github.com/repos/cakephp/cakephp/issues/8486","repository_url":"https://api.github.com/repos/cakephp/cakephp","labels_url":"https://api.github.com/repos/cakephp/cakephp/issues/8486/labels{/name}","comments_url":"https://api.github.com/repos/cakephp/cakephp/issues/8486/comments","events_url":"https://api.github.com/repos/cakephp/cakephp/issues/8486/events","html_url":"https://github.com/cakephp/cakephp/issues/8486","id":141735338,"number":8486,"title":"3.2.5 - Finding via a BTM association failing if either junction table contains a dot","user":{"login":"patrickconroy","id":954577,"avatar_url":"https://avatars.githubusercontent.com/u/954577?v=3","gravatar_id":"","url":"https://api.github.com/users/patrickconroy","html_url":"https://github.com/patrickconroy","followers_url":"https://api.github.com/users/patrickconroy/followers","following_url":"https://api.github.com/users/patrickconroy/following{/other_user}","gists_url":"https://api.github.com/users/patrickconroy/gists{/gist_id}","starred_url":"https://api.github.com/users/patrickconroy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/patrickconroy/subscriptions","organizations_url":"https://api.github.com/users/patrickconroy/orgs","repos_url":"https://api.github.com/users/patrickconroy/repos","events_url":"https://api.github.com/users/patrickconroy/events{/privacy}","received_events_url":"https://api.github.com/users/patrickconroy/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/cakephp/cakephp/labels/ORM","name":"ORM","color":"ffffff"}],"state":"closed","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/cakephp/cakephp/milestones/83","html_url":"https://github.com/cakephp/cakephp/milestones/3.2.6","labels_url":"https://api.github.com/repos/cakephp/cakephp/milestones/83/labels","id":1641774,"number":83,"title":"3.2.6","description":"Bugfixes and optimizations to 3.2.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":35,"closed_issues":19,"state":"open","created_at":"2016-03-14T03:29:34Z","updated_at":"2016-03-18T03:17:44Z","due_on":"2016-04-03T04:00:00Z","closed_at":null},"comments":1,"created_at":"2016-03-17T23:36:48Z","updated_at":"2016-03-18T03:17:44Z","closed_at":"2016-03-18T03:17:44Z","body":"This is a (multiple allowed):\r\n* [x] bug\r\n* [ ] enhancement\r\n* [ ] feature-discussion (RFC)\r\n\r\n* CakePHP Version: 3.2.5\r\n* Platform and Target: PHP 5.6.10, MAMP running Apache\r\n\r\n### What you did\r\nWhen trying to run a `find` directly on a BTM association e.g. `$this->A->B->find()` (instead of using the `TableRegistry`), I'm seeing an error since the core doesn't know where the junction table is. I don't think this always happened.\r\nI have two tables, `A belongsToMany B`. `A`'s `table()` value is `database.a` and `B`'s `table()` value is `database.b`. In `BelongsToMany::_junctionTableName` the `tableNames` array becomes `database.a_database.b`, when it should be just `a_b`. It seems like this:\r\n```\r\n$tablesNames = array_map('\\Cake\\Utility\\Inflector::underscore', [\r\n    $this->source()->table(),\r\n    $this->target()->table()\r\n]);\r\n```\r\nShould be this:\r\n```\r\n$tablesNames = array_map('\\Cake\\Utility\\Inflector::underscore', [\r\n    $this->source()->alias(),\r\n    $this->target()->alias()\r\n]);\r\n```\r\nFor now I'm specifying the `throughTable` directly and it works.\r\n\r\n### Expected Behavior\r\nFinding via the association should work normally without needing to specify the `throughTable`.\r\n\r\n### Actual Behavior\r\nThis tries to use `TableRegistry::get('database.a_database.b')` which doesn't exist."},"comment":{"url":"https://api.github.com/repos/cakephp/cakephp/issues/comments/198182993","html_url":"https://github.com/cakephp/cakephp/issues/8486#issuecomment-198182993","issue_url":"https://api.github.com/repos/cakephp/cakephp/issues/8486","id":198182993,"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},"created_at":"2016-03-18T03:17:44Z","updated_at":"2016-03-18T03:17:44Z","body":"We used to use `alias()` but has to switch to table names because of #6344. Changing this behavior now will result in a different group of sad folks. You'll need to set the `joinTable` option when your tablenames contain a database prefix."}}