@@ -22,8 +22,8 @@ func (h *multiHook) BeforeConnect(ctx context.Context, err error) (context.Conte
22
22
}
23
23
24
24
func (h * multiHook ) AfterConnect (ctx context.Context , dc driver.Conn , err error ) (context.Context , driver.Conn , error ) {
25
- for _ , hook := range h .hooks {
26
- ctx , dc , err = hook .AfterConnect (ctx , dc , err )
25
+ for i := len ( h .hooks ) - 1 ; i >= 0 ; i -- {
26
+ ctx , dc , err = h . hooks [ i ] .AfterConnect (ctx , dc , err )
27
27
}
28
28
29
29
return ctx , dc , err
@@ -38,8 +38,8 @@ func (h *multiHook) BeforeExecContext(ctx context.Context, query string, args []
38
38
}
39
39
40
40
func (h * multiHook ) AfterExecContext (ctx context.Context , query string , args []driver.NamedValue , r driver.Result , err error ) (context.Context , driver.Result , error ) {
41
- for _ , hook := range h .hooks {
42
- ctx , r , err = hook .AfterExecContext (ctx , query , args , r , err )
41
+ for i := len ( h .hooks ) - 1 ; i >= 0 ; i -- {
42
+ ctx , r , err = h . hooks [ i ] .AfterExecContext (ctx , query , args , r , err )
43
43
}
44
44
45
45
return ctx , r , err
@@ -54,8 +54,8 @@ func (h *multiHook) BeforeBeginTx(ctx context.Context, opts driver.TxOptions, er
54
54
}
55
55
56
56
func (h * multiHook ) AfterBeginTx (ctx context.Context , opts driver.TxOptions , dd driver.Tx , err error ) (context.Context , driver.Tx , error ) {
57
- for _ , hook := range h .hooks {
58
- ctx , dd , err = hook .AfterBeginTx (ctx , opts , dd , err )
57
+ for i := len ( h .hooks ) - 1 ; i >= 0 ; i -- {
58
+ ctx , dd , err = h . hooks [ i ] .AfterBeginTx (ctx , opts , dd , err )
59
59
}
60
60
61
61
return ctx , dd , err
@@ -70,9 +70,8 @@ func (h *multiHook) BeforeQueryContext(ctx context.Context, query string, args [
70
70
}
71
71
72
72
func (h * multiHook ) AfterQueryContext (ctx context.Context , query string , args []driver.NamedValue , rows driver.Rows , err error ) (context.Context , driver.Rows , error ) {
73
- for _ , hook := range h .hooks {
74
- ctx , rows , err = hook .AfterQueryContext (ctx , query , args , rows , err )
75
-
73
+ for i := len (h .hooks ) - 1 ; i >= 0 ; i -- {
74
+ ctx , rows , err = h .hooks [i ].AfterQueryContext (ctx , query , args , rows , err )
76
75
}
77
76
78
77
return ctx , rows , err
@@ -87,8 +86,8 @@ func (h *multiHook) BeforePrepareContext(ctx context.Context, query string, err
87
86
}
88
87
89
88
func (h * multiHook ) AfterPrepareContext (ctx context.Context , query string , s driver.Stmt , err error ) (context.Context , driver.Stmt , error ) {
90
- for _ , hook := range h .hooks {
91
- ctx , s , err = hook .AfterPrepareContext (ctx , query , s , err )
89
+ for i := len ( h .hooks ) - 1 ; i >= 0 ; i -- {
90
+ ctx , s , err = h . hooks [ i ] .AfterPrepareContext (ctx , query , s , err )
92
91
}
93
92
94
93
return ctx , s , err
@@ -103,8 +102,8 @@ func (h *multiHook) BeforeCommit(ctx context.Context, err error) (context.Contex
103
102
}
104
103
105
104
func (h * multiHook ) AfterCommit (ctx context.Context , err error ) (context.Context , error ) {
106
- for _ , hook := range h .hooks {
107
- ctx , err = hook .AfterCommit (ctx , err )
105
+ for i := len ( h .hooks ) - 1 ; i >= 0 ; i -- {
106
+ ctx , err = h . hooks [ i ] .AfterCommit (ctx , err )
108
107
}
109
108
110
109
return ctx , err
@@ -119,8 +118,8 @@ func (h *multiHook) BeforeRollback(ctx context.Context, err error) (context.Cont
119
118
}
120
119
121
120
func (h * multiHook ) AfterRollback (ctx context.Context , err error ) (context.Context , error ) {
122
- for _ , hook := range h .hooks {
123
- ctx , err = hook .AfterRollback (ctx , err )
121
+ for i := len ( h .hooks ) - 1 ; i >= 0 ; i -- {
122
+ ctx , err = h . hooks [ i ] .AfterRollback (ctx , err )
124
123
}
125
124
126
125
return ctx , err
@@ -135,8 +134,8 @@ func (h *multiHook) BeforeStmtQueryContext(ctx context.Context, query string, ar
135
134
}
136
135
137
136
func (h * multiHook ) AfterStmtQueryContext (ctx context.Context , query string , args []driver.NamedValue , rows driver.Rows , err error ) (context.Context , driver.Rows , error ) {
138
- for _ , hook := range h .hooks {
139
- ctx , rows , err = hook .AfterStmtQueryContext (ctx , query , args , rows , err )
137
+ for i := len ( h .hooks ) - 1 ; i >= 0 ; i -- {
138
+ ctx , rows , err = h . hooks [ i ] .AfterStmtQueryContext (ctx , query , args , rows , err )
140
139
}
141
140
142
141
return ctx , rows , err
@@ -151,8 +150,8 @@ func (h *multiHook) BeforeStmtExecContext(ctx context.Context, query string, arg
151
150
}
152
151
153
152
func (h * multiHook ) AfterStmtExecContext (ctx context.Context , query string , args []driver.NamedValue , r driver.Result , err error ) (context.Context , driver.Result , error ) {
154
- for _ , hook := range h .hooks {
155
- ctx , r , err = hook .AfterStmtExecContext (ctx , query , args , r , err )
153
+ for i := len ( h .hooks ) - 1 ; i >= 0 ; i -- {
154
+ ctx , r , err = h . hooks [ i ] .AfterStmtExecContext (ctx , query , args , r , err )
156
155
}
157
156
158
157
return ctx , r , err
0 commit comments