-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Open
Labels
type:with reproduction stepswith reproduction stepswith reproduction steps
Description
GORM Playground Link
Description
We have a table definition goes like the following:
type Payload struct {
ID string
}
type Table struct {
ID string `gorm:"primaryKey;type:uuid"`
Payload Payload `gorm:"serializer:json;type:jsonb;default:'{}'"`
}
We noticed that every time we run the auto migration, GORM always executes the SQL ALTER TABLE <table> ALTER COLUMN payload SET DEFAULT '{}' to set the default value, even though it hasn’t changed.
After some investigation, I found that GORM interprets the default value as '{}' when parsing the struct, but retrieves it as {} from the online database. This mismatch causes GORM to attempt to update the default value every time, even when it hasn’t changed.
twocs and RockChinQ
Metadata
Metadata
Assignees
Labels
type:with reproduction stepswith reproduction stepswith reproduction steps