From f9223721cf5a9578464150b7ac4d59ecb7c96748 Mon Sep 17 00:00:00 2001 From: dusan-embroker Date: Wed, 1 Jun 2016 21:02:16 +0200 Subject: [PATCH] Add PropagatedError field --- main.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/main.go b/main.go index 179c91cc..910e3293 100644 --- a/main.go +++ b/main.go @@ -22,6 +22,7 @@ var NowFunc = func() time.Time { type DB struct { Value interface{} Error error + PropagatedError error RowsAffected int64 callback *callback db sqlCommon @@ -296,7 +297,7 @@ func (s *DB) Save(value interface{}) *DB { } else { result = scope.callCallbacks(s.parent.callback.updates).db } - s.Error = result.Error + s.PropagatedError = result.Error return result } @@ -307,14 +308,14 @@ func (s *DB) Create(value interface{}) *DB { func (s *DB) Delete(value interface{}, where ...interface{}) *DB { result := s.clone().NewScope(value).inlineCondition(where...).callCallbacks(s.parent.callback.deletes).db - s.Error = result.Error + s.PropagatedError = result.Error return result } func (s *DB) Raw(sql string, values ...interface{}) *DB { result := s.clone().search.Raw(true).Where(sql, values...).db result.values["__orig"] = s - s.Error = result.Error + s.PropagatedError = result.Error return result } @@ -324,7 +325,7 @@ func (s *DB) Exec(sql string, values ...interface{}) *DB { generatedSql = strings.TrimSuffix(strings.TrimPrefix(generatedSql, "("), ")") scope.Raw(generatedSql) result := scope.Exec().db - s.Error = result.Error + s.PropagatedError = result.Error return result }