{"action":"closed","issue":{"url":"https://api.github.com/repos/jinzhu/gorm/issues/1171","repository_url":"https://api.github.com/repos/jinzhu/gorm","labels_url":"https://api.github.com/repos/jinzhu/gorm/issues/1171/labels{/name}","comments_url":"https://api.github.com/repos/jinzhu/gorm/issues/1171/comments","events_url":"https://api.github.com/repos/jinzhu/gorm/issues/1171/events","html_url":"https://github.com/jinzhu/gorm/issues/1171","id":174594517,"number":1171,"title":"Many-To-Many not uses TableName() in relation [BUG]","user":{"login":"ergoz","id":805154,"avatar_url":"https://avatars.githubusercontent.com/u/805154?v=3","gravatar_id":"","url":"https://api.github.com/users/ergoz","html_url":"https://github.com/ergoz","followers_url":"https://api.github.com/users/ergoz/followers","following_url":"https://api.github.com/users/ergoz/following{/other_user}","gists_url":"https://api.github.com/users/ergoz/gists{/gist_id}","starred_url":"https://api.github.com/users/ergoz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ergoz/subscriptions","organizations_url":"https://api.github.com/users/ergoz/orgs","repos_url":"https://api.github.com/users/ergoz/repos","events_url":"https://api.github.com/users/ergoz/events{/privacy}","received_events_url":"https://api.github.com/users/ergoz/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-09-01T18:35:07Z","updated_at":"2016-09-13T00:17:22Z","closed_at":"2016-09-13T00:17:22Z","body":"I have this code:\r\n\r\n```go\r\n\r\ntype MethodDB struct {\r\n\tId           int     `gorm:\"primary_key\"`\r\n\tName         string  `sql:\"size:255;not null;unique\"` with this tag\r\n}\r\n\r\nfunc (c MethodDB) TableName() string {\r\n\treturn \"methods\"\r\n}\r\n\r\ntype UserDB struct {\r\n\tId           int      `gorm:\"primary_key\"`\r\n\tLogin        string   `sql:\"type:varchar(20);not null;unique\"`\r\n\tPassword     string   `sql:\"type:varchar(40)\"`\r\n\tEmail        string   `sql:\"size:255\"`\r\n\tStatus       int      `sql:\"type:int(2);not null;DEFAULT:0\"`\r\n\tMethods      []MethodDB `gorm:\"many2many:user2method;\"`\r\n}\r\n\r\nfunc (c UserDB) TableName() string {\r\n\treturn \"users\"\r\n}\r\n\r\n```\r\nBut when i try to run this code\r\n```go\r\n\tvar u UserDB\r\n\tdb := DBConn.Preload(\"Methods\", MethodDB{Name:method}).First(&u, UserDB{Login: user})\r\n```\r\nmany to many relation use ```user2method.user_db_id``` but it should use ```user2method.users_id```\r\nThis relation ignore ```func (c UserDB) TableName()```"}}
{"actor":{"display_login":"jinzhu"}}