bug: `db.Ping` is a no op
avinassh opened this issue · comments
Connection interface has a Ping
method which pings the server and checks if the server is up: https://pkg.go.dev/database/sql#DB.PingContext
Since we don't implement it, even if the server is unreachable, ping does not report any errors. To fix it, we can use a simple query like SELECT 1
Here is a regression test:
import (
"database/sql"
"fmt"
"os"
_ "github.com/tursodatabase/libsql-client-go/libsql"
)
var dbUrl = "http://127.0.0.1:8080" // some non existent server
db, err := sql.Open("libsql", dbUrl)
if err != nil {
//
}
db, err := db.Ping()
if err != nil {
// this never runs
}
I can take a look at this one
feel free to @webstradev! 😄