Skip to content

Commit

Permalink
Should use global NowFunc when trace SQL
Browse files Browse the repository at this point in the history
  • Loading branch information
jinzhu committed Dec 5, 2019
1 parent 11e2819 commit 5490a87
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion callback_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion callback_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func queryCallback(scope *Scope) {
return
}

defer scope.trace(scope.db.nowFunc())
defer scope.trace(NowFunc())

var (
isSlice, isPtr bool
Expand Down
6 changes: 3 additions & 3 deletions scope.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit 5490a87

Please sign in to comment.