From 1c62bf1e5794f9db023e7a3f450788e071bd7bd3 Mon Sep 17 00:00:00 2001 From: Momo733 <1550526230@qq.com> Date: Sat, 13 Apr 2019 14:23:35 +0800 Subject: [PATCH] fix save err when specify a table name s.New() will clear all search conditions and search value,when I use Table() to set a table name. Then FirstOrCreate() will use struct name as my database table name,so It doesn't work. --- main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.go b/main.go index fda63d29..927bd5af 100644 --- a/main.go +++ b/main.go @@ -444,7 +444,7 @@ func (s *DB) Save(value interface{}) *DB { if !scope.PrimaryKeyZero() { newDB := scope.callCallbacks(s.parent.callbacks.updates).db if newDB.Error == nil && newDB.RowsAffected == 0 { - return s.New().FirstOrCreate(value) + return s.FirstOrCreate(value) } return newDB }