GORM Playground Link

https://github.com/go-gorm/playground/pull/605 Description

Hi!

Planet, when does not have id, this must be retreived from db due this has a default generate_uuid_v4()

When struct has the default:generate_uuid_v4() tag gets the uuid from db, but when you provide the id manually this is not included in query

I'd like to fullfil both with a single struct and not using BeforeCreate hook (this is what I have done to "fix" this by the moment).

I've got an anware in issue #6363, but I did not write test in the way I explained myself better

Comment From: black-06

What does "this is not included in query" mean?

type Planet struct {
    ID uuid.UUID `gorm:"type:UUID;default:gen_random_uuid()"`
    PlanetData
    IsBig bool
}

This struct can work with your test.

Comment From: manicar2093

Wooow! Thanks, that fixed my problem! 😃

Oh! I meant when I add the Id to an instance this should be in the query to be inserted.

You are awesome! GORM is really a savior!

Comment From: black-06

I will close this issue,. If you have any other questions, please feel free to ask them.