Open joaojeronimo opened 10 years ago
You haven't set the key in dbmap
. Since DbMap.AddTable
returns a *TableMap
, you can chain AddTable
call with SetKeys
, like this:
dbmap.AddTable(User{}, "users").SetKeys(true, "id")
That should solve your problem.
I'm using PostgreSQL and in my table I have the primary key like
Which means that
INSERT INTO users (name) VALUES ("Bob");
will work, and postgresql will generate a UUID in the id column.I'm trying to do the same with modl, but as the field id is empty in my struct, apparently modl is filling with an empty string (
""
) and pg complains that's not a valid uuid type.I this panic
PANIC: pq: invalid input syntax for uuid: ""
How can I achieve this ? I tried using
db:"-"
in theId
field, and that worked for the insert, but that makes it harder to use the same struct after.