Skip to content

Commit 99dfd8d

Browse files
Fix dbo plugin Scope hook
1 parent 55baf38 commit 99dfd8d

File tree

1 file changed

+1
-8
lines changed

1 file changed

+1
-8
lines changed

dbo/plugin.go

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ func (x *xPlugin) onBeforeQuery() xPluginCallback {
3535

3636
model := reflect.New(db.Statement.Schema.ModelType)
3737

38-
scopeList := []scopes.Scope{}
39-
4038
// Process Scopes
4139
for i := 0; i < model.NumMethod(); i++ {
4240
name := model.Type().Method(i).Name
@@ -45,16 +43,11 @@ func (x *xPlugin) onBeforeQuery() xPluginCallback {
4543
method, ok := model.Method(i).Interface().(scopes.Scope)
4644

4745
if ok {
48-
scopeList = append(scopeList, method)
49-
// db = method(db)
46+
db = method(db)
5047
}
5148
}
5249
}
5350

54-
if len(scopeList) > 0 {
55-
db = db.Scopes(scopeList...)
56-
}
57-
5851
// Process Tags
5952
for _, field := range db.Statement.Schema.Fields {
6053
method := model.MethodByName("Preload" + field.Name)

0 commit comments

Comments
 (0)