Should use global NowFunc when trace SQL

This commit is contained in:
Jinzhu 2019-12-06 00:01:40 +08:00
parent 11e2819f44
commit 5490a87fe9
3 changed files with 5 additions and 5 deletions

View File

@ -50,7 +50,7 @@ func updateTimeStampForCreateCallback(scope *Scope) {
// createCallback the callback used to insert data into database // createCallback the callback used to insert data into database
func createCallback(scope *Scope) { func createCallback(scope *Scope) {
if !scope.HasError() { if !scope.HasError() {
defer scope.trace(scope.db.nowFunc()) defer scope.trace(NowFunc())
var ( var (
columns, placeholders []string columns, placeholders []string

View File

@ -24,7 +24,7 @@ func queryCallback(scope *Scope) {
return return
} }
defer scope.trace(scope.db.nowFunc()) defer scope.trace(NowFunc())
var ( var (
isSlice, isPtr bool isSlice, isPtr bool

View File

@ -358,7 +358,7 @@ func (scope *Scope) Raw(sql string) *Scope {
// Exec perform generated SQL // Exec perform generated SQL
func (scope *Scope) Exec() *Scope { func (scope *Scope) Exec() *Scope {
defer scope.trace(scope.db.nowFunc()) defer scope.trace(NowFunc())
if !scope.HasError() { if !scope.HasError() {
if result, err := scope.SQLDB().Exec(scope.SQL, scope.SQLVars...); scope.Err(err) == nil { 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 { func (scope *Scope) row() *sql.Row {
defer scope.trace(scope.db.nowFunc()) defer scope.trace(NowFunc())
result := &RowQueryResult{} result := &RowQueryResult{}
scope.InstanceSet("row_query_result", result) scope.InstanceSet("row_query_result", result)
@ -944,7 +944,7 @@ func (scope *Scope) row() *sql.Row {
} }
func (scope *Scope) rows() (*sql.Rows, error) { func (scope *Scope) rows() (*sql.Rows, error) {
defer scope.trace(scope.db.nowFunc()) defer scope.trace(NowFunc())
result := &RowsQueryResult{} result := &RowsQueryResult{}
scope.InstanceSet("row_query_result", result) scope.InstanceSet("row_query_result", result)