Skip to content

Commit 51d311d

Browse files
fix(helper): skip nil fields entirely in update instead of setting to NULL
1 parent 7ecc103 commit 51d311d

1 file changed

Lines changed: 1 addition & 4 deletions

File tree

go/helper/struct_cache.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -298,20 +298,17 @@ func ExtractUpdateValues(tmpl *UpdateTemplateInfo, structVal reflect.Value, anot
298298
field := structVal.FieldByIndex(fp.IndexPath)
299299
value := field.Interface()
300300

301-
// Handle null.String — skip if not Valid (SQL NULL)
301+
// Handle null.String — skip if not Valid
302302
if fp.IsNullType {
303303
if ns, ok := value.(null.String); ok {
304304
if !ns.Valid {
305-
// This field is NULL — add "=null" and skip value
306-
result.Cols = append(result.Cols, fp.ColName+"=null")
307305
continue
308306
}
309307
}
310308
}
311309

312310
// Handle nil pointers — skip
313311
if field.Kind() == reflect.Ptr && field.IsNil() {
314-
result.Cols = append(result.Cols, fp.ColName+"=null")
315312
continue
316313
}
317314

0 commit comments

Comments
 (0)