mirror of https://github.com/go-gorm/gorm.git
Apply Before('gorm:row_query') for row query callbacks w/o specify order for compatibility
This commit is contained in:
parent
a3b8b332ed
commit
7fb9b62c17
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue