{"action":"created","issue":{"url":"https://api.github.com/repos/go-pg/pg/issues/377","repository_url":"https://api.github.com/repos/go-pg/pg","labels_url":"https://api.github.com/repos/go-pg/pg/issues/377/labels{/name}","comments_url":"https://api.github.com/repos/go-pg/pg/issues/377/comments","events_url":"https://api.github.com/repos/go-pg/pg/issues/377/events","html_url":"https://github.com/go-pg/pg/issues/377","id":185180432,"number":377,"title":"Support for setting model's table dynamically","user":{"login":"serg472","id":1200229,"avatar_url":"https://avatars.githubusercontent.com/u/1200229?v=3","gravatar_id":"","url":"https://api.github.com/users/serg472","html_url":"https://github.com/serg472","followers_url":"https://api.github.com/users/serg472/followers","following_url":"https://api.github.com/users/serg472/following{/other_user}","gists_url":"https://api.github.com/users/serg472/gists{/gist_id}","starred_url":"https://api.github.com/users/serg472/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/serg472/subscriptions","organizations_url":"https://api.github.com/users/serg472/orgs","repos_url":"https://api.github.com/users/serg472/repos","events_url":"https://api.github.com/users/serg472/events{/privacy}","received_events_url":"https://api.github.com/users/serg472/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-10-25T17:19:45Z","updated_at":"2016-10-25T17:55:12Z","closed_at":null,"body":"Currently it's not possible change a table name of a model dynamically, it is either autoguessed from the model name or defined inside `model.TableName`. This makes it impossible to work with multiple temporary tables of the same structure through ORM.\r\n\r\n\ttype MyModel struct {\r\n\t    TableName struct{} `sql:\"temp_table1\"`\r\n\t    Id              int64\r\n\t    Name            string  \r\n\t}\r\n\t\r\n\tvar mymodels []MyModel\r\n\terr := db.Model(&mymodels).Column(\"mymodel.id\", \"mymodel.name\").Select()\r\n\r\nNow if those temp tables are dynamically created the only choice seems to be using raw queries to query them.\r\n\r\nThanks.\r\n"},"comment":{"url":"https://api.github.com/repos/go-pg/pg/issues/comments/256110466","html_url":"https://github.com/go-pg/pg/issues/377#issuecomment-256110466","issue_url":"https://api.github.com/repos/go-pg/pg/issues/377","id":256110466,"user":{"login":"serg472","id":1200229,"avatar_url":"https://avatars.githubusercontent.com/u/1200229?v=3","gravatar_id":"","url":"https://api.github.com/users/serg472","html_url":"https://github.com/serg472","followers_url":"https://api.github.com/users/serg472/followers","following_url":"https://api.github.com/users/serg472/following{/other_user}","gists_url":"https://api.github.com/users/serg472/gists{/gist_id}","starred_url":"https://api.github.com/users/serg472/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/serg472/subscriptions","organizations_url":"https://api.github.com/users/serg472/orgs","repos_url":"https://api.github.com/users/serg472/repos","events_url":"https://api.github.com/users/serg472/events{/privacy}","received_events_url":"https://api.github.com/users/serg472/received_events","type":"User","site_admin":false},"created_at":"2016-10-25T17:55:12Z","updated_at":"2016-10-25T17:55:12Z","body":"Thanks, this worked."}}
{"actor":{"display_login":"serg472"}}