Open ystyle opened 1 year ago
Sounds like a GORM issue to me. I don't use it and I can't provide support for it.
I would suggest that after you unmarshal the JSON input, check whether null.Time
is properly set to null or not. If it looks OK, then it's almost certainly a GORM issue.
The result is the same whether the time type is passed or not, how to set a zero value for the time
I feel a better option would be to use the Golang stdlib data structures for null SQL values. Those will generally be supported by all Golang ORMs, including GORM as their documentation on model declaration specifically uses them (https://gorm.io/docs/models.html).
The relevant type here would be: sql.NullTime (https://pkg.go.dev/database/sql#NullTime)
Unfortunately, you will need to have logic to copy the data from the source type into the destination type. However, you would have incurred that "extra" step no matter what.
defind web api dto struct
send this json to web api
service: use gorm update entry
Hope to generate sql