{"action":"created","issue":{"url":"https://api.github.com/repos/cakephp/bake/issues/236","repository_url":"https://api.github.com/repos/cakephp/bake","labels_url":"https://api.github.com/repos/cakephp/bake/issues/236/labels{/name}","comments_url":"https://api.github.com/repos/cakephp/bake/issues/236/comments","events_url":"https://api.github.com/repos/cakephp/bake/issues/236/events","html_url":"https://github.com/cakephp/bake/issues/236","id":145996513,"number":236,"title":"Bake confused by \"_id\" field name.","user":{"login":"ADmad","id":142658,"avatar_url":"https://avatars.githubusercontent.com/u/142658?v=3","gravatar_id":"","url":"https://api.github.com/users/ADmad","html_url":"https://github.com/ADmad","followers_url":"https://api.github.com/users/ADmad/followers","following_url":"https://api.github.com/users/ADmad/following{/other_user}","gists_url":"https://api.github.com/users/ADmad/gists{/gist_id}","starred_url":"https://api.github.com/users/ADmad/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ADmad/subscriptions","organizations_url":"https://api.github.com/users/ADmad/orgs","repos_url":"https://api.github.com/users/ADmad/repos","events_url":"https://api.github.com/users/ADmad/events{/privacy}","received_events_url":"https://api.github.com/users/ADmad/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/cakephp/bake/labels/bug","name":"bug","color":"fc2929"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/cakephp/bake/milestones/20","html_url":"https://github.com/cakephp/bake/milestones/1.2.3","labels_url":"https://api.github.com/repos/cakephp/bake/milestones/20/labels","id":1640182,"number":20,"title":"1.2.3","description":"Bugfixes and minor enhancements.","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":4,"closed_issues":2,"state":"open","created_at":"2016-03-12T03:49:32Z","updated_at":"2016-04-08T17:26:22Z","due_on":null,"closed_at":null},"comments":4,"created_at":"2016-04-05T13:55:37Z","updated_at":"2016-04-29T12:38:56Z","closed_at":null,"body":"_From @thinkingmedia on April 5, 2016 13:45_\n\nThis is a (multiple allowed):\r\n* [x] bug\r\n* [ ] enhancement\r\n* [ ] feature-discussion (RFC)\r\n\r\n* CakePHP Version: 3.2.6\r\n* Platform and Target: Apache2, MySQL, Php 7\r\n\r\n### What you did\r\n\r\nAdded a field named `_id` as an integer to the MySQL table. It was not the primary key of the table as it already had an `id` field that is uuid. \r\n\r\nThe `_id` is just a field to store an reference value from a third-party source.\r\n\r\n### Expected Behavior\r\n\r\nBake to treat this field as regular value field.\r\n\r\nI understand that the field name \"_id\" does not follow Cake naming conventions. I needed the prefix since all field names mapped to  third-party JSON fields. This just made my job of processing data easier.\r\n\r\n### Actual Behavior\r\n\r\nBake generated an empty `belongsTo` association in the table.\r\n\r\n```\r\n        $this->belongsTo('', [\r\n            'foreignKey' => '_id',\r\n            'joinType' => 'INNER',\r\n            'className' => 'TheMovieDB.'\r\n        ]);\r\n```\r\n\r\nBake generated an empty `@property` in the table.\r\n\r\n```\r\n/**\r\n * Genres Model\r\n *\r\n * @property \\Cake\\ORM\\Association\\BelongsTo $\r\n * @property \\Cake\\ORM\\Association\\BelongsToMany $Movies\r\n * @property \\Cake\\ORM\\Association\\BelongsToMany $TvShows\r\n */\r\n```\r\n\r\nBake generated an empty `@property` in the entity.\r\n\r\n```\r\n/**\r\n * Genre Entity.\r\n *\r\n * @property string $id\r\n * @property int $_id\r\n * @property \\TheMovieDB\\Model\\Entity\\ $\r\n * @property string $name\r\n * \r\n * @property \\Cake\\I18n\\Time $created\r\n * @property \\Cake\\I18n\\Time $modified\r\n */\r\n```\r\n\r\n> Note: TheMovieDB is the name of my plugin.\r\n\r\nI assume that this can be an easy fix. Bake just needs to validate the format of a field name before treating it as an associated. I think bake is just checking if it ends in `_id`. It needs to end with `_id` and be more then 3 characters.\n\n_Copied from original issue: cakephp/cakephp#8595_"},"comment":{"url":"https://api.github.com/repos/cakephp/bake/issues/comments/215700093","html_url":"https://github.com/cakephp/bake/issues/236#issuecomment-215700093","issue_url":"https://api.github.com/repos/cakephp/bake/issues/236","id":215700093,"user":{"login":"thinkingmedia","id":551022,"avatar_url":"https://avatars.githubusercontent.com/u/551022?v=3","gravatar_id":"","url":"https://api.github.com/users/thinkingmedia","html_url":"https://github.com/thinkingmedia","followers_url":"https://api.github.com/users/thinkingmedia/followers","following_url":"https://api.github.com/users/thinkingmedia/following{/other_user}","gists_url":"https://api.github.com/users/thinkingmedia/gists{/gist_id}","starred_url":"https://api.github.com/users/thinkingmedia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thinkingmedia/subscriptions","organizations_url":"https://api.github.com/users/thinkingmedia/orgs","repos_url":"https://api.github.com/users/thinkingmedia/repos","events_url":"https://api.github.com/users/thinkingmedia/events{/privacy}","received_events_url":"https://api.github.com/users/thinkingmedia/received_events","type":"User","site_admin":false},"created_at":"2016-04-29T12:38:56Z","updated_at":"2016-04-29T12:38:56Z","body":"@ionas the table columns match fieldnames from json. To keep importing simple I didn't want to rename anything and the json already has `id`. So to track fieldnames that are not part of the json I prefix them with `_`. So I added a `_id`.\r\n\r\nIt's not really a normal thing to do. "}}