From d926a05bec9ab9ee6f8bc6d865c1ccdf9350c74b Mon Sep 17 00:00:00 2001 From: "kouha.shu" Date: Wed, 23 Oct 2019 10:38:05 +0900 Subject: [PATCH 1/2] add warning comment --- main.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index eac28f8a..5dda8838 100644 --- a/main.go +++ b/main.go @@ -433,7 +433,8 @@ func (s *DB) FirstOrCreate(out interface{}, where ...interface{}) *DB { return c } -// Update update attributes with callbacks, refer: https://jinzhu.github.io/gorm/crud.html#update +// Update update attributes with callbacks. refer: https://jinzhu.github.io/gorm/crud.html#update +// WARNING when update with struct, GORM will not update fields that with zero value func (s *DB) Update(attrs ...interface{}) *DB { return s.Updates(toSearchableMap(attrs...), true) } @@ -480,6 +481,7 @@ func (s *DB) Create(value interface{}) *DB { } // Delete delete value match given conditions, if the value has primary key, then will including the primary key as condition +// WARNING If model has DeletedAt field, GORM will only set field DeletedAt's value to current time func (s *DB) Delete(value interface{}, where ...interface{}) *DB { return s.NewScope(value).inlineCondition(where...).callCallbacks(s.parent.callbacks.deletes).db } From 2ee239a4c07c9e3f9948500cf01f667e89a7986d Mon Sep 17 00:00:00 2001 From: "kouha.shu" Date: Wed, 23 Oct 2019 10:40:34 +0900 Subject: [PATCH 2/2] Update main.go --- main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.go b/main.go index 5dda8838..e39a868a 100644 --- a/main.go +++ b/main.go @@ -433,7 +433,7 @@ func (s *DB) FirstOrCreate(out interface{}, where ...interface{}) *DB { return c } -// Update update attributes with callbacks. refer: https://jinzhu.github.io/gorm/crud.html#update +// Update update attributes with callbacks, refer: https://jinzhu.github.io/gorm/crud.html#update // WARNING when update with struct, GORM will not update fields that with zero value func (s *DB) Update(attrs ...interface{}) *DB { return s.Updates(toSearchableMap(attrs...), true)