Description

Interesting, when I defined a entity struct using a nested id module, which tagged with gorm:"embedded", after inserting, I want to use id related to other record, but the id is zero. why? if the id defined directly in that struct, it's ok. so, I don't know. the demo like follow:

type IdModule struct {
    Id int64 `gorm:"autoIncrement;not null"`
}

type TimeModule struct {
    CreatedAt time.Time `json:"created_at" gorm:"column:created_at"`
    UpdatedAt time.Time `json:"updated_at" gorm:"column:updated_at"`
}

type Test struct {
    IdModule   `gorm:"embedded"`
    Name          string `gorm:"type:varchar(128);not null;default:''"`
    TimeModule `gorm:"embedded"`
}

test := &entity.Test{Name: "测试"}
_ = db.DB{}.Get().Create(test)
fmt.Println("id", test.Id) // this is zero.

Comment From: github-actions[bot]

The issue has been automatically marked as stale as it missing playground pull request link, which is important to help others understand your issue effectively and make sure the issue hasn't been fixed on latest master, checkout https://github.com/go-gorm/playground for details. it will be closed in 30 days if no further activity occurs. if you are asking question, please use the Question template, most likely your question already answered https://github.com/go-gorm/gorm/issues or described in the document https://gorm.io ✨ Search Before Asking