I am facing a weird issue with postgres usage in Golang. This is what I am doing. I need to get the UID after inserting a new user. Instead when I log the uid after scanning I see a time stamp along with the uid.
var uid int
err := database.Handle.QueryRow("INSERT INTO users (username, isactive) values ($1,TRUE) RETURNING uid", username).Scan(&uid)
log(uid)
RESULT –
2018/02/24 06:12:17 sandyk
Need help guys to understand how this is happening. My DB create statement is as follows :-
Create table users ( uid serial not null,
username character varying(200) not null,
isactive boolean not null,
created timestamp default now());
Thanks for responding. I mean I did use uid of type int right?
I ended up fixing it by changing table create statment into –
Create table users ( uid serial not null,
username character varying(200) not null,
isactive boolean not null,
created timestamp default now())
WITH(OIDS=FALSE);