Your Question

In document of "Updates multiple columns":

When update with struct, GORM will only update non-zero fields,

and in doc of "Struct & Map Conditions" refs to a example of zero values:

The zero value is:

0 for numeric types, false for the boolean type, and "" (the empty string) for strings.

But, is it a zero value that a pointer to an empty string?

I try to update a struct with a field of a point to string, which is a "zero-value" string. It works.

My question is the behavior above is by-design?

The document you expected this should be explained

https://gorm.io/docs/update.html#Updates-multiple-columns

Expected answer

If it is by-design, I suggest change the description to "When update with struct, GORM will only update non-zero or *** non-nil *** fields, ... ". Because "non-zero" is a bit of confused for me.

Best wishes.

Comment From: li-jin-gou

hello,because zero-value is type default value, and pointer point to "",so it is not pointer type zero-value and it works.