forked from mirror/gorm
Don't sort processors that without name
This commit is contained in:
parent
4e8370e18b
commit
5d4aae2d11
30
callback.go
30
callback.go
|
@ -128,9 +128,9 @@ func (cp *CallbackProcessor) Replace(callbackName string, callback func(scope *S
|
||||||
// Get registered callback
|
// Get registered callback
|
||||||
// db.Callback().Create().Get("gorm:create")
|
// db.Callback().Create().Get("gorm:create")
|
||||||
func (cp *CallbackProcessor) Get(callbackName string) (callback func(scope *Scope)) {
|
func (cp *CallbackProcessor) Get(callbackName string) (callback func(scope *Scope)) {
|
||||||
for _, processor := range cp.parent.processors {
|
for _, p := range cp.parent.processors {
|
||||||
if processor.name == callbackName && processor.kind == cp.kind && !cp.remove {
|
if p.name == callbackName && p.kind == cp.kind && !cp.remove {
|
||||||
return *cp.processor
|
return *p.processor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
@ -215,17 +215,19 @@ func (c *Callback) reorder() {
|
||||||
var creates, updates, deletes, queries, rowQueries []*CallbackProcessor
|
var creates, updates, deletes, queries, rowQueries []*CallbackProcessor
|
||||||
|
|
||||||
for _, processor := range c.processors {
|
for _, processor := range c.processors {
|
||||||
switch processor.kind {
|
if processor.name != "" {
|
||||||
case "create":
|
switch processor.kind {
|
||||||
creates = append(creates, processor)
|
case "create":
|
||||||
case "update":
|
creates = append(creates, processor)
|
||||||
updates = append(updates, processor)
|
case "update":
|
||||||
case "delete":
|
updates = append(updates, processor)
|
||||||
deletes = append(deletes, processor)
|
case "delete":
|
||||||
case "query":
|
deletes = append(deletes, processor)
|
||||||
queries = append(queries, processor)
|
case "query":
|
||||||
case "row_query":
|
queries = append(queries, processor)
|
||||||
rowQueries = append(rowQueries, processor)
|
case "row_query":
|
||||||
|
rowQueries = append(rowQueries, processor)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue