Skip to content

Commit

Permalink
Apply Before('gorm:row_query') for row query callbacks w/o specify or…
Browse files Browse the repository at this point in the history
…der for compatibility
  • Loading branch information
jinzhu committed Jan 16, 2017
1 parent a3b8b33 commit 7fb9b62
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions callback.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,13 @@ func (cp *CallbackProcessor) Before(callbackName string) *CallbackProcessor {

// Register a new callback, refer `Callbacks.Create`
func (cp *CallbackProcessor) Register(callbackName string, callback func(scope *Scope)) {
if cp.kind == "row_query" {
if cp.before == "" && cp.after == "" && callbackName != "gorm:row_query" {
fmt.Printf("Registing RowQuery callback %v without specify order with Before(), After(), applying Before('gorm:row_query') by default for compatibility...\n", callbackName)
cp.before = "gorm:row_query"
}
}

cp.name = callbackName
cp.processor = &callback
cp.parent.processors = append(cp.parent.processors, cp)
Expand Down

0 comments on commit 7fb9b62

Please sign in to comment.