@@ -190,9 +190,9 @@ func (conn *Conn) Exec(query string, args []driver.Value) (driver.Result, error)
190
190
}
191
191
192
192
// ExecContext calls the original ExecContext (or Exec as a fallback) method of the connection.
193
- // It will trigger PreExec, PostExec hooks.
193
+ // It will trigger PreExec, Exec, PostExec hooks.
194
194
//
195
- // If the original connection doesn't satisfy "database/sql/driver".ExecerContext nor "database/sql/driver".Execer, it return ErrSkip error.
195
+ // If the original connection does not satisfy "database/sql/driver".ExecerContext nor "database/sql/driver".Execer, it return ErrSkip error.
196
196
func (conn * Conn ) ExecContext (c context.Context , query string , args []driver.NamedValue ) (driver.Result , error ) {
197
197
execer , exOk := conn .Conn .(driver.Execer )
198
198
execerCtx , exCtxOk := conn .Conn .(driver.ExecerContext )
@@ -257,10 +257,11 @@ func (conn *Conn) Query(query string, args []driver.Value) (driver.Rows, error)
257
257
// QueryContext executes a query that may return rows.
258
258
// It wil trigger PreQuery, Query, PostQuery hooks.
259
259
//
260
- // If the original connection does not satisfy "database/sql/driver".Queryer, it return ErrSkip error.
260
+ // If the original connection does not satisfy "database/sql/driver".QueryerContext nor "database/sql/driver". Queryer, it return ErrSkip error.
261
261
func (conn * Conn ) QueryContext (c context.Context , query string , args []driver.NamedValue ) (driver.Rows , error ) {
262
- queryer , ok := conn .Conn .(driver.Queryer )
263
- if ! ok {
262
+ queryer , qok := conn .Conn .(driver.Queryer )
263
+ queryerCtx , qCtxOk := conn .Conn .(driver.QueryerContext )
264
+ if ! qok && ! qCtxOk {
264
265
return nil , driver .ErrSkip
265
266
}
266
267
@@ -281,7 +282,7 @@ func (conn *Conn) QueryContext(c context.Context, query string, args []driver.Na
281
282
}
282
283
283
284
// call the original method.
284
- if queryerCtx , ok := conn . Conn .(driver. QueryerContext ); ok {
285
+ if queryerCtx != nil {
285
286
rows , err = queryerCtx .QueryContext (c , stmt .QueryString , args )
286
287
} else {
287
288
select {
0 commit comments