mgutz / dat

Go Postgres Data Access Toolkit
Other
610 stars 62 forks source link

pg dat.NullTime still causes 'cannot parse time errors' (Different format for timestamps without timezone) #41

Open vinzenz opened 8 years ago

vinzenz commented 8 years ago
dat_test=# create table test (time timestamp without time zone NOT NULL DEFAULT (now() AT TIME ZONE 'utc'), name TEXT NOT NULL);
CREATE TABLE
dat_test=# insert into test (name) VALUES('Hello');
INSERT 0 1
dat_test=# select row_to_json(fields.*) FROM (SELECT * FROM test) as fields;
                     row_to_json                      
------------------------------------------------------
 {"time":"2016-03-02T10:30:26.256081","name":"Hello"}
(1 row)

It seems like that postgres, at least with version 9.5, if using a row without timestamp without time zone reports the data in the above format

When adding "2006-01-02T15:04:05.000000" to the supported formats, in types.go, it works

Edit: Additional note: this happens when using SelectDoc only of course but I think that's clear to you when you see the row_to_json