{"action":"created","issue":{"url":"https://api.github.com/repos/jinzhu/gorm/issues/433","labels_url":"https://api.github.com/repos/jinzhu/gorm/issues/433/labels{/name}","comments_url":"https://api.github.com/repos/jinzhu/gorm/issues/433/comments","events_url":"https://api.github.com/repos/jinzhu/gorm/issues/433/events","html_url":"https://github.com/jinzhu/gorm/issues/433","id":63508619,"number":433,"title":"Create changes ID","user":{"login":"actuallyKasi","id":5820155,"avatar_url":"https://avatars.githubusercontent.com/u/5820155?v=3","gravatar_id":"","url":"https://api.github.com/users/actuallyKasi","html_url":"https://github.com/actuallyKasi","followers_url":"https://api.github.com/users/actuallyKasi/followers","following_url":"https://api.github.com/users/actuallyKasi/following{/other_user}","gists_url":"https://api.github.com/users/actuallyKasi/gists{/gist_id}","starred_url":"https://api.github.com/users/actuallyKasi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/actuallyKasi/subscriptions","organizations_url":"https://api.github.com/users/actuallyKasi/orgs","repos_url":"https://api.github.com/users/actuallyKasi/repos","events_url":"https://api.github.com/users/actuallyKasi/events{/privacy}","received_events_url":"https://api.github.com/users/actuallyKasi/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-03-22T08:38:26Z","updated_at":"2015-04-03T09:17:25Z","closed_at":"2015-04-03T09:17:25Z","body":"I am inserting a record in db. I see that right after inserting same ID in struct changes to null/invalid. Am I doing something wrong here?\r\n\r\ntype App struct {\r\n\tID    string `sql:\"not null;unique\"`\r\n\tName  string `sql:\"not null\"`\r\n\tEmail string `sql:\"not null\" `\r\n}\r\n\r\napp := App{ID: \"w13\", Name: \"bigfoot\", Email: \"someone@example.com\"}\r\nfmt.Println(app)\r\n\tdb.Create(&app)\r\n\tfmt.Println(\"---\" + app.ID + \"---\")\r\nOutput\r\n---------\r\n{w14 website someone@example.com}\r\n------"},"comment":{"url":"https://api.github.com/repos/jinzhu/gorm/issues/comments/89233516","html_url":"https://github.com/jinzhu/gorm/issues/433#issuecomment-89233516","issue_url":"https://api.github.com/repos/jinzhu/gorm/issues/433","id":89233516,"user":{"login":"jinzhu","id":6843,"avatar_url":"https://avatars.githubusercontent.com/u/6843?v=3","gravatar_id":"","url":"https://api.github.com/users/jinzhu","html_url":"https://github.com/jinzhu","followers_url":"https://api.github.com/users/jinzhu/followers","following_url":"https://api.github.com/users/jinzhu/following{/other_user}","gists_url":"https://api.github.com/users/jinzhu/gists{/gist_id}","starred_url":"https://api.github.com/users/jinzhu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jinzhu/subscriptions","organizations_url":"https://api.github.com/users/jinzhu/orgs","repos_url":"https://api.github.com/users/jinzhu/repos","events_url":"https://api.github.com/users/jinzhu/events{/privacy}","received_events_url":"https://api.github.com/users/jinzhu/received_events","type":"User","site_admin":false},"created_at":"2015-04-03T09:17:25Z","updated_at":"2015-04-03T09:17:25Z","body":"seems works for me?\r\n\r\n```go\r\npackage main\r\n\r\nimport (\r\n\t\"fmt\"\r\n\r\n\t\"github.com/jinzhu/gorm\"\r\n\t_ \"github.com/mattn/go-sqlite3\"\r\n)\r\n\r\ntype App struct {\r\n\tID    string `sql:\"not null;unique\"`\r\n\tName  string `sql:\"not null\"`\r\n\tEmail string `sql:\"not null\"`\r\n}\r\n\r\nfunc main() {\r\n\tdb, _ := gorm.Open(\"sqlite3\", \"/tmp/gorm.db\")\r\n\tdb.LogMode(true)\r\n\tdb.AutoMigrate(&App{})\r\n\r\n\tapp := App{ID: \"w13\", Name: \"bigfoot\", Email: \"someone@example.com\"}\r\n\tfmt.Println(app)\r\n\r\n\tdb.Create(&app)\r\n\tfmt.Println(\"---\" + app.ID + \"---\")\r\n\tapp = App{ID: \"w13\", Name: \"bigfoot2\", Email: \"someone@example.com\"}\r\n\tfmt.Println(app)\r\n\tdb.Create(&app)\r\n\tfmt.Println(\"---\" + app.ID + \"---\")\r\n}\r\n```\r\n\r\nI got \r\n\r\n```go\r\n(<autogenerated>:102) \r\n[2015-04-03 17:01:14]  [0.88ms]  SELECT count(*) FROM sqlite_master WHERE type='table' AND name='apps'\r\n\r\n(/home/jinzhu/c.go:19) \r\n[2015-04-03 17:01:14]  [0.55ms]  CREATE TABLE \"apps\" (\"id\" varchar(255) NOT NULL UNIQUE,\"name\" varchar(255) NOT NULL ,\"email\" varchar(255) NOT NULL  , PRIMARY KEY (id))\r\n{w13 bigfoot someone@example.com}\r\n\r\n(/home/jinzhu/c.go:24) \r\n[2015-04-03 17:01:14]  [0.36ms]  INSERT INTO \"apps\" (\"id\",\"name\",\"email\") VALUES ('w13','bigfoot','someone@example.com') \r\n------\r\n{w13 bigfoot2 someone@example.com}\r\n\r\n(/home/jinzhu/c.go:28) \r\n[2015-04-03 17:01:14]  UNIQUE constraint failed: apps.id \r\n\r\n(/home/jinzhu/c.go:28) \r\n[2015-04-03 17:01:14]  [0.48ms]  INSERT INTO \"apps\" (\"id\",\"name\",\"email\") VALUES ('w13','bigfoot2','someone@example.com') \r\n---w13---\r\n```"}}