@@ -189,13 +189,14 @@ func (conn *Conn) Exec(query string, args []driver.Value) (driver.Result, error)
189
189
panic ("not supported" )
190
190
}
191
191
192
- // ExecContext calls the original Exec method of the connection.
193
- // It will trigger PreExec, Exec, PostExec hooks.
192
+ // ExecContext calls the original ExecContext (or Exec as a fallback) method of the connection.
193
+ // It will trigger PreExec, PostExec hooks.
194
194
//
195
- // If the original connection does not satisfy "database/sql/driver".Execer, it return ErrSkip error.
195
+ // If the original connection doesn't 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
- execer , ok := conn .Conn .(driver.Execer )
198
- if ! ok {
197
+ execer , exOk := conn .Conn .(driver.Execer )
198
+ execerCtx , exCtxOk := conn .Conn .(driver.ExecerContext )
199
+ if ! exOk && ! exCtxOk {
199
200
return nil , driver .ErrSkip
200
201
}
201
202
@@ -217,7 +218,7 @@ func (conn *Conn) ExecContext(c context.Context, query string, args []driver.Nam
217
218
}
218
219
219
220
// call the original method.
220
- if execerCtx , ok := execer .(driver. ExecerContext ); ok {
221
+ if execerCtx != nil {
221
222
result , err = execerCtx .ExecContext (c , stmt .QueryString , args )
222
223
} else {
223
224
select {
0 commit comments