go-gorm / gorm

The fantastic ORM library for Golang, aims to be developer friendly
https://gorm.io
MIT License
36.77k stars 3.93k forks source link

Updating associations, does not omit default (zero) values #5932

Open dimowski opened 1 year ago

dimowski commented 1 year ago

Your Question

When updating with association using gorm.Session{FullSaveAssociations: true}) and .Updates() method it updates main model skipping zero values, but for association it behaves differently. It updates all fields including zero values, although one would expect that main model and associations should have same behaviour during update.

So maybe there are some ways to update association ignoring zero values?

The document you expected this should be explained

I didn't find options to skip updating zero values for associations in documentation. There are Omit options but it only works for particular columns: https://gorm.io/docs/associations.html#Skip-Auto-Create-x2F-Update

I found similar issues related to this, but with no response: https://github.com/go-gorm/gorm/issues/5724

Expected answer

ankit16-19 commented 5 months ago

@jinzhu I can also reproduce this. Do we have any update or work around on this?