From 018a7e69ec81c6afb673ecee0dee85e3f1394c46 Mon Sep 17 00:00:00 2001 From: Jinzhu Date: Mon, 17 Aug 2015 16:38:01 +0800 Subject: [PATCH] Handle DB error in callbacks --- scope.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scope.go b/scope.go index 7b6764a6..fe3fccc3 100644 --- a/scope.go +++ b/scope.go @@ -213,7 +213,9 @@ func (scope *Scope) CallMethod(name string, checkError bool) { case func(s *Scope) error: scope.Err(f(scope)) case func(s *DB) error: - scope.Err(f(scope.NewDB())) + newDB := scope.NewDB() + scope.Err(f(newDB)) + scope.Err(newDB.Error) default: scope.Err(fmt.Errorf("unsupported function %v", name)) }