Skip to content

Commit

Permalink
Don't sort processors that without name
Browse files Browse the repository at this point in the history
  • Loading branch information
jinzhu committed Feb 15, 2016
1 parent 4e8370e commit 5d4aae2
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions callback.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,9 @@ func (cp *CallbackProcessor) Replace(callbackName string, callback func(scope *S
// Get registered callback
// db.Callback().Create().Get("gorm:create")
func (cp *CallbackProcessor) Get(callbackName string) (callback func(scope *Scope)) {
for _, processor := range cp.parent.processors {
if processor.name == callbackName && processor.kind == cp.kind && !cp.remove {
return *cp.processor
for _, p := range cp.parent.processors {
if p.name == callbackName && p.kind == cp.kind && !cp.remove {
return *p.processor
}
}
return nil
Expand Down Expand Up @@ -215,17 +215,19 @@ func (c *Callback) reorder() {
var creates, updates, deletes, queries, rowQueries []*CallbackProcessor

for _, processor := range c.processors {
switch processor.kind {
case "create":
creates = append(creates, processor)
case "update":
updates = append(updates, processor)
case "delete":
deletes = append(deletes, processor)
case "query":
queries = append(queries, processor)
case "row_query":
rowQueries = append(rowQueries, processor)
if processor.name != "" {
switch processor.kind {
case "create":
creates = append(creates, processor)
case "update":
updates = append(updates, processor)
case "delete":
deletes = append(deletes, processor)
case "query":
queries = append(queries, processor)
case "row_query":
rowQueries = append(rowQueries, processor)
}
}
}

Expand Down

0 comments on commit 5d4aae2

Please sign in to comment.