Skip to content

Commit d926a05

Browse files
committed
add warning comment
1 parent 795328f commit d926a05

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

main.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,8 @@ func (s *DB) FirstOrCreate(out interface{}, where ...interface{}) *DB {
433433
return c
434434
}
435435

436-
// Update update attributes with callbacks, refer: https://jinzhu.github.io/gorm/crud.html#update
436+
// Update update attributes with callbacks. refer: https://jinzhu.github.io/gorm/crud.html#update
437+
// WARNING when update with struct, GORM will not update fields that with zero value
437438
func (s *DB) Update(attrs ...interface{}) *DB {
438439
return s.Updates(toSearchableMap(attrs...), true)
439440
}
@@ -480,6 +481,7 @@ func (s *DB) Create(value interface{}) *DB {
480481
}
481482

482483
// Delete delete value match given conditions, if the value has primary key, then will including the primary key as condition
484+
// WARNING If model has DeletedAt field, GORM will only set field DeletedAt's value to current time
483485
func (s *DB) Delete(value interface{}, where ...interface{}) *DB {
484486
return s.NewScope(value).inlineCondition(where...).callCallbacks(s.parent.callbacks.deletes).db
485487
}

0 commit comments

Comments
 (0)