From 5490a87fe9f9d72a38cfa641e7965bf48f588b87 Mon Sep 17 00:00:00 2001 From: Jinzhu Date: Fri, 6 Dec 2019 00:01:40 +0800 Subject: [PATCH] Should use global NowFunc when trace SQL --- callback_create.go | 2 +- callback_query.go | 2 +- scope.go | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/callback_create.go b/callback_create.go index 3527858b..5271dc29 100644 --- a/callback_create.go +++ b/callback_create.go @@ -50,7 +50,7 @@ func updateTimeStampForCreateCallback(scope *Scope) { // createCallback the callback used to insert data into database func createCallback(scope *Scope) { if !scope.HasError() { - defer scope.trace(scope.db.nowFunc()) + defer scope.trace(NowFunc()) var ( columns, placeholders []string diff --git a/callback_query.go b/callback_query.go index e3b3d534..7facc42b 100644 --- a/callback_query.go +++ b/callback_query.go @@ -24,7 +24,7 @@ func queryCallback(scope *Scope) { return } - defer scope.trace(scope.db.nowFunc()) + defer scope.trace(NowFunc()) var ( isSlice, isPtr bool diff --git a/scope.go b/scope.go index 0e9dfd1c..d82cadbc 100644 --- a/scope.go +++ b/scope.go @@ -358,7 +358,7 @@ func (scope *Scope) Raw(sql string) *Scope { // Exec perform generated SQL func (scope *Scope) Exec() *Scope { - defer scope.trace(scope.db.nowFunc()) + defer scope.trace(NowFunc()) if !scope.HasError() { if result, err := scope.SQLDB().Exec(scope.SQL, scope.SQLVars...); scope.Err(err) == nil { @@ -934,7 +934,7 @@ func (scope *Scope) updatedAttrsWithValues(value interface{}) (results map[strin } func (scope *Scope) row() *sql.Row { - defer scope.trace(scope.db.nowFunc()) + defer scope.trace(NowFunc()) result := &RowQueryResult{} scope.InstanceSet("row_query_result", result) @@ -944,7 +944,7 @@ func (scope *Scope) row() *sql.Row { } func (scope *Scope) rows() (*sql.Rows, error) { - defer scope.trace(scope.db.nowFunc()) + defer scope.trace(NowFunc()) result := &RowsQueryResult{} scope.InstanceSet("row_query_result", result)