2
0

Only test numeric infinity on PG 14+

This commit is contained in:
Jack Christensen
2022-03-26 11:38:31 -05:00
parent 600c4fd931
commit 3a6d9490e5
2 changed files with 35 additions and 6 deletions
+21
View File
@@ -4,6 +4,8 @@ import (
"database/sql"
"errors"
"net"
"regexp"
"strconv"
"testing"
"github.com/jackc/pgx/v5"
@@ -76,6 +78,25 @@ func skipCockroachDB(t testing.TB, msg string) {
}
}
func skipPostgreSQLVersionLessThan(t testing.TB, minVersion int64) {
conn := testutil.MustConnectPgx(t)
defer testutil.MustCloseContext(t, conn)
serverVersionStr := conn.PgConn().ParameterStatus("server_version")
serverVersionStr = regexp.MustCompile(`^[0-9]+`).FindString(serverVersionStr)
// if not PostgreSQL do nothing
if serverVersionStr == "" {
return
}
serverVersion, err := strconv.ParseInt(serverVersionStr, 10, 64)
require.NoError(t, err)
if serverVersion < minVersion {
t.Skipf("Test requires PostgreSQL v%d+", minVersion)
}
}
func TestTypeMapScanNilIsNoOp(t *testing.T) {
m := pgtype.NewMap()