Skip to content

Commit

Permalink
Add query callback nil check
Browse files Browse the repository at this point in the history
  • Loading branch information
jinzhu committed Jun 8, 2022
1 parent 691098d commit eb6a9f6
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions clauses.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ func (op Operation) ModifyStatement(stmt *gorm.Statement) {

if optName != "" {
stmt.Clauses[optName] = clause.Clause{}
stmt.DB.Callback().Query().Get("gorm:db_resolver")(stmt.DB)
if fc := stmt.DB.Callback().Query().Get("gorm:db_resolver"); fc != nil {
fc(stmt.DB)
}
}
}

Expand All @@ -46,7 +48,9 @@ const usingName = "gorm:db_resolver:using"
// ModifyStatement modify operation mode
func (u using) ModifyStatement(stmt *gorm.Statement) {
stmt.Clauses[usingName] = clause.Clause{Expression: u}
stmt.DB.Callback().Query().Get("gorm:db_resolver")(stmt.DB)
if fc := stmt.DB.Callback().Query().Get("gorm:db_resolver"); fc != nil {
fc(stmt.DB)
}
}

// Build implements clause.Expression interface
Expand Down

0 comments on commit eb6a9f6

Please sign in to comment.