File tree 2 files changed +19
-0
lines changed
2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -353,3 +353,21 @@ func (conn *Conn) ResetSession(ctx context.Context) error {
353
353
}
354
354
return err
355
355
}
356
+
357
+ // the same as driver.Validator.
358
+ // Copied from database/sql/driver/driver.go for supporting Go 1.15
359
+ type validator interface {
360
+ // IsValid is called prior to placing the connection into the
361
+ // connection pool. The connection will be discarded if false is returned.
362
+ IsValid () bool
363
+ }
364
+
365
+ // IsValid implements driver.Validator.
366
+ // It calls the IsValid method of the original connection.
367
+ // If the original connection does not satisfy "database/sql/driver".Validator, it always returns true.
368
+ func (conn * Conn ) IsValid () bool {
369
+ if v , ok := conn .Conn .(validator ); ok {
370
+ return v .IsValid ()
371
+ }
372
+ return true
373
+ }
Original file line number Diff line number Diff line change @@ -12,3 +12,4 @@ var _ driver.Queryer = (*Conn)(nil)
12
12
var _ driver.QueryerContext = (* Conn )(nil )
13
13
var _ namedValueChecker = (* Conn )(nil )
14
14
var _ sessionResetter = (* Conn )(nil )
15
+ var _ validator = (* Conn )(nil )
You can’t perform that action at this time.
0 commit comments