File tree 2 files changed +8
-1
lines changed
2 files changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -79,7 +79,7 @@ func (cn *conn) Ping(ctx context.Context) error {
79
79
if finish := cn .watchCancel (ctx ); finish != nil {
80
80
defer finish ()
81
81
}
82
- rows , err := cn .simpleQuery ("SELECT 'lib/pq ping test' ;" )
82
+ rows , err := cn .simpleQuery (";" )
83
83
if err != nil {
84
84
return driver .ErrBadConn // https://golang.org/pkg/database/sql/driver/#Pinger
85
85
}
Original file line number Diff line number Diff line change @@ -55,6 +55,13 @@ func TestPing(t *testing.T) {
55
55
if rows .Err () != nil {
56
56
t .Fatal (err )
57
57
}
58
+ // Fail the transaction and make sure we can still ping.
59
+ if _ , err := tx .Query ("INVALID SQL" ); err == nil {
60
+ t .Fatal ("expected error" )
61
+ }
62
+ if err := conn .PingContext (ctx ); err != nil {
63
+ t .Fatal (err )
64
+ }
58
65
if err := tx .Rollback (); err != nil {
59
66
t .Fatal (err )
60
67
}
You can’t perform that action at this time.
0 commit comments