mirror of https://github.com/jackc/pgx.git
Fix PG version extraction in tests
parent
46abba674f
commit
339cda3fed
|
@ -6,10 +6,10 @@ import (
|
||||||
"database/sql"
|
"database/sql"
|
||||||
"database/sql/driver"
|
"database/sql/driver"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
|
||||||
"math"
|
"math"
|
||||||
"os"
|
"os"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
"regexp"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -55,6 +55,7 @@ func skipPostgreSQLVersion(t testing.TB, db *sql.DB, constraintStr, msg string)
|
||||||
err = conn.Raw(func(driverConn interface{}) error {
|
err = conn.Raw(func(driverConn interface{}) error {
|
||||||
conn := driverConn.(*stdlib.Conn).Conn()
|
conn := driverConn.(*stdlib.Conn).Conn()
|
||||||
serverVersionStr := conn.PgConn().ParameterStatus("server_version")
|
serverVersionStr := conn.PgConn().ParameterStatus("server_version")
|
||||||
|
serverVersionStr = regexp.MustCompile(`^[0-9.]+`).FindString(serverVersionStr)
|
||||||
// if not PostgreSQL do nothing
|
// if not PostgreSQL do nothing
|
||||||
if serverVersionStr == "" {
|
if serverVersionStr == "" {
|
||||||
return nil
|
return nil
|
||||||
|
@ -62,12 +63,12 @@ func skipPostgreSQLVersion(t testing.TB, db *sql.DB, constraintStr, msg string)
|
||||||
|
|
||||||
serverVersion, err := semver.NewVersion(serverVersionStr)
|
serverVersion, err := semver.NewVersion(serverVersionStr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("%s: %w", serverVersionStr, err)
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
c, err := semver.NewConstraint(constraintStr)
|
c, err := semver.NewConstraint(constraintStr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("%s: %w", constraintStr, err)
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if c.Check(serverVersion) {
|
if c.Check(serverVersion) {
|
||||||
|
|
Loading…
Reference in New Issue