{"action":"opened","issue":{"url":"https://api.github.com/repos/knq/xo/issues/48","repository_url":"https://api.github.com/repos/knq/xo","labels_url":"https://api.github.com/repos/knq/xo/issues/48/labels{/name}","comments_url":"https://api.github.com/repos/knq/xo/issues/48/comments","events_url":"https://api.github.com/repos/knq/xo/issues/48/events","html_url":"https://github.com/knq/xo/issues/48","id":177599894,"number":48,"title":"Scan error on column : converting driver.Value type time.Time to a int64","user":{"login":"da-crystal","id":2936170,"avatar_url":"https://avatars.githubusercontent.com/u/2936170?v=3","gravatar_id":"","url":"https://api.github.com/users/da-crystal","html_url":"https://github.com/da-crystal","followers_url":"https://api.github.com/users/da-crystal/followers","following_url":"https://api.github.com/users/da-crystal/following{/other_user}","gists_url":"https://api.github.com/users/da-crystal/gists{/gist_id}","starred_url":"https://api.github.com/users/da-crystal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/da-crystal/subscriptions","organizations_url":"https://api.github.com/users/da-crystal/orgs","repos_url":"https://api.github.com/users/da-crystal/repos","events_url":"https://api.github.com/users/da-crystal/events{/privacy}","received_events_url":"https://api.github.com/users/da-crystal/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-09-17T19:07:29Z","updated_at":"2016-09-17T19:07:29Z","closed_at":null,"body":"`xo` generate the following postgres types as int64:\r\n- “time with time zone\"\r\n- “time without time zone\"\r\n- “timestamp without time zone\" \r\n\r\nThis behaviour will rise the following error: \r\n\r\n`\r\nsql: Scan error on column index 0: converting driver.Value type time.Time (\"2016-09-17 15:35:37.816458 +0000 +0000\") to a int64\r\n`\r\n\r\n\r\nBased on `github.com/lib/pq` driver, those should be of type `time.time` or `pq.NullTime`:\r\n\r\n### Test:\r\n```Go\r\nfunc main() {\r\n\tdb, err := sql.Open(\"postgres\", \"dbname=test01 user=postgres  host=localhost sslmode=disable\")\r\n\tif err != nil {\r\n\t\tlog.Fatal(err)\r\n\t}\r\n\r\n\tpgtypes := []string{\r\n\t\t\"date\",\r\n\t\t\"timestamp without time zone\",\r\n\t\t\"timestamp with time zone\",\r\n\t\t\"time without time zone\",\r\n\t\t\"time with time zone\"}\r\n\tfor _, t := range pgtypes {\r\n\t\tv := new(interface{})\r\n\t\trows, _ := db.Query(fmt.Sprintf(\"SELECT $1::%v\", t), \"2013-01-04 20:14:58.80033\")\r\n\t\t// row.Scan(v)\r\n\t\trows.Next()\r\n\t\tc, _ := rows.Columns()\r\n\t\trows.Scan(v)\r\n\r\n\t\tfmt.Printf(\"Go: %T\\tPG: %-30v PG-Short: %v\\n\", *v, t, c[0])\r\n\t}\r\n}\r\n```\r\n\r\n\r\n### Output:\r\n```\r\nGo: time.Time   PG: date                           PG-Short: date\r\nGo: time.Time   PG: timestamp without time zone    PG-Short: timestamp\r\nGo: time.Time   PG: timestamp with time zone       PG-Short: timestamptz                                                                                   \r\nGo: time.Time   PG: time without time zone         PG-Short: time\r\nGo: time.Time   PG: time with time zone            PG-Short: timetz\r\n```\r\n\r\n\r\n#### This fixed the issue for me:\r\n```diff\r\ndiff --git a/loaders/postgres.go b/loaders/postgres.go\r\nindex a027c99..7cade4f 100644\r\n--- a/loaders/postgres.go\r\n+++ b/loaders/postgres.go\r\n@@ -151,20 +151,13 @@ func PgParseType(args *internal.ArgType, dt string, nullable bool) (int, string,\r\n                typ = \"byte\"\r\n \r\n        case \"date\", \"timestamp with time zone\":\r\n+       case \"time with time zone\", \"time without time zone\", \"timestamp without time zone\":\r\n                typ = \"*time.Time\"\r\n                if nullable {\r\n                        nilVal = \"pq.NullTime{}\"\r\n                        typ = \"pq.NullTime\"\r\n                }\r\n \r\n-       case \"time with time zone\", \"time without time zone\", \"timestamp without time zone\":\r\n-               nilVal = \"0\"\r\n-               typ = \"int64\"\r\n-               if nullable {\r\n-                       nilVal = \"sql.NullInt64{}\"\r\n-                       typ = \"sql.NullInt64\"\r\n-               }\r\n-\r\n        case \"interval\":\r\n                typ = \"*time.Duration\"\r\n \r\n```\r\n\r\n"}}
{"actor":{"display_login":"da-crystal"}}