You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi! I believe the erros is not related to missing ID on return. Have you tried this on ID?
Note: I believe that you will need to test using only postgresql and than add uuid extension CREATE EXTENSION IF NOT EXISTS "uuid-ossp"
ID uuid.UUID`gorm:"type:uuid;default:uuid_generate_v4()" json:"id"`
GORM Playground Link
go-gorm/playground#713
Description
type Sample struct {
ID string ``gorm:"size:128;default:(uuid())" json:"id"``
Status string ``gorm:"size:256; default:''; not null" json:"status"``
}
This is a table in which string field gets autopopulated. Either by any trigger, or in this case by the uuid function invoked on default.
w := Sample{Status: "12345"}
err = DB.Create(&w).Error
Now I check w.ID -> instead of containing newly created UUID, its contains empty string .
If ID is int (autoincrement), then this works. But if ID is string, then it fails.
DB.Create() should be able to get the ID column (independent of its type being int or string)
The text was updated successfully, but these errors were encountered: