From 781a8183906a286ba46024ffe2cf94f957acffa4 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 1316dbd3..ec84906b 100644 --- a/main.go +++ b/main.go @@ -466,7 +466,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 }