From 7cc033adf1e2ee307342df2cf496eeba19614798 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Nieto?= Date: Sun, 23 Jun 2024 17:17:28 -0600 Subject: [PATCH 1/2] upgrade to pgx/v5 --- adapter/cockroachdb/connection_pgx.go | 3 +-- adapter/cockroachdb/connection_pgx_test.go | 14 +++++++------- adapter/cockroachdb/database_pgx.go | 8 ++++++-- adapter/cockroachdb/database_pq.go | 6 +++++- adapter/postgresql/connection.go | 5 ++++- adapter/postgresql/connection_pgx.go | 2 +- adapter/postgresql/connection_pgx_test.go | 15 +++++++-------- adapter/postgresql/database_pgx.go | 10 ++++++++-- adapter/postgresql/database_pq.go | 6 +++++- go.mod | 1 + go.sum | 18 ++++++++++++++++++ internal/testsuite/generic_suite.go | 1 + 12 files changed, 64 insertions(+), 25 deletions(-) diff --git a/adapter/cockroachdb/connection_pgx.go b/adapter/cockroachdb/connection_pgx.go index 695d6126..c03fdce3 100644 --- a/adapter/cockroachdb/connection_pgx.go +++ b/adapter/cockroachdb/connection_pgx.go @@ -81,8 +81,7 @@ func (c ConnectionURL) String() (s string) { c.Options["sslmode"] = "prefer" } - // Disabled by default - c.Options["statement_cache_capacity"] = "0" + c.Options["default_query_exec_mode"] = "cache_describe" for k, v := range c.Options { u = append(u, escaper.Replace(k)+"="+escaper.Replace(v)) diff --git a/adapter/cockroachdb/connection_pgx_test.go b/adapter/cockroachdb/connection_pgx_test.go index 2c27e1b8..c9c1afa3 100644 --- a/adapter/cockroachdb/connection_pgx_test.go +++ b/adapter/cockroachdb/connection_pgx_test.go @@ -38,33 +38,33 @@ func TestConnectionURL(t *testing.T) { // Adding a host with port. c.Host = "localhost:1234" - assert.Equal(t, "host=localhost port=1234 sslmode=prefer statement_cache_capacity=0", c.String()) + assert.Equal(t, "default_query_exec_mode=cache_describe host=localhost port=1234 sslmode=prefer", c.String()) // Adding a host. c.Host = "localhost" - assert.Equal(t, "host=localhost port=26257 sslmode=prefer statement_cache_capacity=0", c.String()) + assert.Equal(t, "default_query_exec_mode=cache_describe host=localhost port=26257 sslmode=prefer", c.String()) // Adding a username. c.User = "Anakin" - assert.Equal(t, `host=localhost port=26257 sslmode=prefer statement_cache_capacity=0 user=Anakin`, c.String()) + assert.Equal(t, `default_query_exec_mode=cache_describe host=localhost port=26257 sslmode=prefer user=Anakin`, c.String()) // Adding a password with special characters. c.Password = "Some Sort of ' Password" - assert.Equal(t, `host=localhost password=Some\ Sort\ of\ \'\ Password port=26257 sslmode=prefer statement_cache_capacity=0 user=Anakin`, c.String()) + assert.Equal(t, `default_query_exec_mode=cache_describe host=localhost password=Some\ Sort\ of\ \'\ Password port=26257 sslmode=prefer user=Anakin`, c.String()) // Adding a port. c.Host = "localhost:1234" - assert.Equal(t, `host=localhost password=Some\ Sort\ of\ \'\ Password port=1234 sslmode=prefer statement_cache_capacity=0 user=Anakin`, c.String()) + assert.Equal(t, `default_query_exec_mode=cache_describe host=localhost password=Some\ Sort\ of\ \'\ Password port=1234 sslmode=prefer user=Anakin`, c.String()) // Adding a database. c.Database = "MyDatabase" - assert.Equal(t, `dbname=MyDatabase host=localhost password=Some\ Sort\ of\ \'\ Password port=1234 sslmode=prefer statement_cache_capacity=0 user=Anakin`, c.String()) + assert.Equal(t, `dbname=MyDatabase default_query_exec_mode=cache_describe host=localhost password=Some\ Sort\ of\ \'\ Password port=1234 sslmode=prefer user=Anakin`, c.String()) // Adding options. c.Options = map[string]string{ "sslmode": "verify-full", } - assert.Equal(t, `dbname=MyDatabase host=localhost password=Some\ Sort\ of\ \'\ Password port=1234 sslmode=verify-full statement_cache_capacity=0 user=Anakin`, c.String()) + assert.Equal(t, `dbname=MyDatabase default_query_exec_mode=cache_describe host=localhost password=Some\ Sort\ of\ \'\ Password port=1234 sslmode=verify-full user=Anakin`, c.String()) } func TestParseConnectionURL(t *testing.T) { diff --git a/adapter/cockroachdb/database_pgx.go b/adapter/cockroachdb/database_pgx.go index 102a1f5f..19c99b10 100644 --- a/adapter/cockroachdb/database_pgx.go +++ b/adapter/cockroachdb/database_pgx.go @@ -30,7 +30,7 @@ import ( "time" - _ "github.com/jackc/pgx/v4/stdlib" + _ "github.com/jackc/pgx/v5/stdlib" "github.com/upper/db/v4" "github.com/upper/db/v4/internal/sqladapter" ) @@ -41,7 +41,11 @@ func (*database) OpenDSN(sess sqladapter.Session, dsn string) (*sql.DB, error) { return nil, err } if tz := connURL.Options["timezone"]; tz != "" { - loc, _ := time.LoadLocation(tz) + loc, err := time.LoadLocation(tz) + if err != nil { + return nil, err + } + ctx := context.WithValue(sess.Context(), db.ContextKey("timezone"), loc) sess.SetContext(ctx) } diff --git a/adapter/cockroachdb/database_pq.go b/adapter/cockroachdb/database_pq.go index ea42c061..3cfb33f9 100644 --- a/adapter/cockroachdb/database_pq.go +++ b/adapter/cockroachdb/database_pq.go @@ -40,7 +40,11 @@ func (*database) OpenDSN(sess sqladapter.Session, dsn string) (*sql.DB, error) { return nil, err } if tz := connURL.Options["timezone"]; tz != "" { - loc, _ := time.LoadLocation(tz) + loc, err := time.LoadLocation(tz) + if err != nil { + return nil, err + } + ctx := context.WithValue(sess.Context(), db.ContextKey("timezone"), loc) sess.SetContext(ctx) } diff --git a/adapter/postgresql/connection.go b/adapter/postgresql/connection.go index ee7a7cd7..35f0eb46 100644 --- a/adapter/postgresql/connection.go +++ b/adapter/postgresql/connection.go @@ -150,7 +150,10 @@ func ParseURL(s string) (u *ConnectionURL, err error) { } if timezone, ok := u.Options["timezone"]; ok { - u.timezone, _ = time.LoadLocation(timezone) + u.timezone, err = time.LoadLocation(timezone) + if err != nil { + return nil, err + } } return u, err diff --git a/adapter/postgresql/connection_pgx.go b/adapter/postgresql/connection_pgx.go index 5cad7682..07987bc1 100644 --- a/adapter/postgresql/connection_pgx.go +++ b/adapter/postgresql/connection_pgx.go @@ -82,7 +82,7 @@ func (c ConnectionURL) String() (s string) { } // Disabled by default - c.Options["statement_cache_capacity"] = "0" + c.Options["default_query_exec_mode"] = "cache_describe" for k, v := range c.Options { u = append(u, escaper.Replace(k)+"="+escaper.Replace(v)) diff --git a/adapter/postgresql/connection_pgx_test.go b/adapter/postgresql/connection_pgx_test.go index ff8b8b52..307b714d 100644 --- a/adapter/postgresql/connection_pgx_test.go +++ b/adapter/postgresql/connection_pgx_test.go @@ -38,37 +38,36 @@ func TestConnectionURL(t *testing.T) { // Adding a host with port. c.Host = "localhost:1234" - assert.Equal(t, "host=localhost port=1234 sslmode=prefer statement_cache_capacity=0", c.String()) + assert.Equal(t, "default_query_exec_mode=cache_describe host=localhost port=1234 sslmode=prefer", c.String()) // Adding a host. c.Host = "localhost" - assert.Equal(t, "host=localhost sslmode=prefer statement_cache_capacity=0", c.String()) + assert.Equal(t, "default_query_exec_mode=cache_describe host=localhost sslmode=prefer", c.String()) // Adding a username. c.User = "Anakin" - assert.Equal(t, `host=localhost sslmode=prefer statement_cache_capacity=0 user=Anakin`, c.String()) + assert.Equal(t, `default_query_exec_mode=cache_describe host=localhost sslmode=prefer user=Anakin`, c.String()) // Adding a password with special characters. c.Password = "Some Sort of ' Password" - assert.Equal(t, `host=localhost password=Some\ Sort\ of\ \'\ Password sslmode=prefer statement_cache_capacity=0 user=Anakin`, c.String()) + assert.Equal(t, `default_query_exec_mode=cache_describe host=localhost password=Some\ Sort\ of\ \'\ Password sslmode=prefer user=Anakin`, c.String()) // Adding a port. c.Host = "localhost:1234" - assert.Equal(t, `host=localhost password=Some\ Sort\ of\ \'\ Password port=1234 sslmode=prefer statement_cache_capacity=0 user=Anakin`, c.String()) + assert.Equal(t, `default_query_exec_mode=cache_describe host=localhost password=Some\ Sort\ of\ \'\ Password port=1234 sslmode=prefer user=Anakin`, c.String()) // Adding a database. c.Database = "MyDatabase" - assert.Equal(t, `dbname=MyDatabase host=localhost password=Some\ Sort\ of\ \'\ Password port=1234 sslmode=prefer statement_cache_capacity=0 user=Anakin`, c.String()) + assert.Equal(t, `dbname=MyDatabase default_query_exec_mode=cache_describe host=localhost password=Some\ Sort\ of\ \'\ Password port=1234 sslmode=prefer user=Anakin`, c.String()) // Adding options. c.Options = map[string]string{ "sslmode": "verify-full", } - assert.Equal(t, `dbname=MyDatabase host=localhost password=Some\ Sort\ of\ \'\ Password port=1234 sslmode=verify-full statement_cache_capacity=0 user=Anakin`, c.String()) + assert.Equal(t, `dbname=MyDatabase default_query_exec_mode=cache_describe host=localhost password=Some\ Sort\ of\ \'\ Password port=1234 sslmode=verify-full user=Anakin`, c.String()) } func TestParseConnectionURL(t *testing.T) { - { s := "postgres://anakin:skywalker@localhost/jedis" u, err := ParseURL(s) diff --git a/adapter/postgresql/database_pgx.go b/adapter/postgresql/database_pgx.go index 6d5a2f3b..bad447c7 100644 --- a/adapter/postgresql/database_pgx.go +++ b/adapter/postgresql/database_pgx.go @@ -29,7 +29,7 @@ import ( "database/sql" "time" - _ "github.com/jackc/pgx/v4/stdlib" + _ "github.com/jackc/pgx/v5/stdlib" "github.com/upper/db/v4" "github.com/upper/db/v4/internal/sqladapter" ) @@ -39,10 +39,16 @@ func (*database) OpenDSN(sess sqladapter.Session, dsn string) (*sql.DB, error) { if err != nil { return nil, err } + if tz := connURL.Options["timezone"]; tz != "" { - loc, _ := time.LoadLocation(tz) + loc, err := time.LoadLocation(tz) + if err != nil { + return nil, err + } + ctx := context.WithValue(sess.Context(), db.ContextKey("timezone"), loc) sess.SetContext(ctx) } + return sql.Open("pgx", dsn) } diff --git a/adapter/postgresql/database_pq.go b/adapter/postgresql/database_pq.go index 2415f624..89377484 100644 --- a/adapter/postgresql/database_pq.go +++ b/adapter/postgresql/database_pq.go @@ -40,7 +40,11 @@ func (*database) OpenDSN(sess sqladapter.Session, dsn string) (*sql.DB, error) { return nil, err } if tz := connURL.Options["timezone"]; tz != "" { - loc, _ := time.LoadLocation(tz) + loc, err := time.LoadLocation(tz) + if err != nil { + return nil, err + } + ctx := context.WithValue(sess.Context(), db.ContextKey("timezone"), loc) sess.SetContext(ctx) } diff --git a/go.mod b/go.mod index 7997a9cc..0621be26 100644 --- a/go.mod +++ b/go.mod @@ -11,6 +11,7 @@ require ( github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect github.com/jackc/pgtype v1.14.3 github.com/jackc/pgx/v4 v4.18.3 + github.com/jackc/pgx/v5 v5.6.0 // indirect github.com/lib/pq v1.10.9 github.com/mattn/go-sqlite3 v1.14.22 github.com/segmentio/fasthash v1.0.3 diff --git a/go.sum b/go.sum index a5371d9f..dbeef3e5 100644 --- a/go.sum +++ b/go.sum @@ -11,6 +11,7 @@ github.com/cockroachdb/apd v1.1.0/go.mod h1:8Sl8LxpKi29FqWXR16WEFZRNSz3SoPzUzeMe github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY= +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -99,19 +100,29 @@ github.com/jackc/pgx/v4 v4.18.1/go.mod h1:FydWkUyadDmdNH/mHnGob881GawxeEm7TcMCzk github.com/jackc/pgx/v4 v4.18.2/go.mod h1:Ey4Oru5tH5sB6tV7hDmfWFahwF15Eb7DNXlRKx2CkVw= github.com/jackc/pgx/v4 v4.18.3 h1:dE2/TrEsGX3RBprb3qryqSV9Y60iZN1C6i8IrmW9/BA= github.com/jackc/pgx/v4 v4.18.3/go.mod h1:Ey4Oru5tH5sB6tV7hDmfWFahwF15Eb7DNXlRKx2CkVw= +github.com/jackc/pgx/v5 v5.6.0 h1:SWJzexBzPL5jb0GEsrPMLIsi/3jOo7RHlzTjcAeDrPY= +github.com/jackc/pgx/v5 v5.6.0/go.mod h1:DNZ/vlrUnhWCoFGxHAG8U2ljioxukquj7utPDgtQdTw= github.com/jackc/puddle v0.0.0-20190413234325-e4ced69a3a2b/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= github.com/jackc/puddle v0.0.0-20190608224051-11cab39313c9/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= github.com/jackc/puddle v1.1.3/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= +github.com/jackc/puddle v1.3.0 h1:eHK/5clGOatcjX3oWGBO/MpxpbHzSwud5EWTSCI+MX0= github.com/jackc/puddle v1.3.0/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= +github.com/jackc/puddle/v2 v2.2.1 h1:RhxXJtFG022u4ibrCSMSiu5aOq1i77R3OHKNJj77OAk= +github.com/jackc/puddle/v2 v2.2.1/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= +github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= +github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/pty v1.1.8/go.mod h1:O1sed60cT9XZ5uDucP5qwvh+TE3NnUj51EiZO/lmSfw= github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= github.com/lib/pq v1.1.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= @@ -138,6 +149,7 @@ github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0/go.mod h1:qq github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE= github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= +github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ= github.com/rs/zerolog v1.13.0/go.mod h1:YbFCdg8HfsridGWAh22vktObvhZbQsZXe4/zB0OKkWU= github.com/rs/zerolog v1.15.0/go.mod h1:xYTKnLHcpfU2225ny5qZjxnj9NvkumZYjJHlAThCjNc= @@ -198,6 +210,7 @@ golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58 golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc= golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc= golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4= +golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU= golang.org/x/crypto v0.20.0/go.mod h1:Xwo95rrVNIoSMx9wa1JroENMToLWn3RNVrTBpLHgZPQ= golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8= @@ -230,6 +243,7 @@ golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -254,6 +268,7 @@ golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.14.0 h1:Vz7Qs629MkJkGyHxUlRHizWJRG2j8fbQKjELVSNhy7Q= golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws= @@ -266,6 +281,7 @@ golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU= golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U= +golang.org/x/term v0.15.0/go.mod h1:BDl952bC7+uMoWR75FIrCDx79TPU9oHkTZ9yRbYOrX0= golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk= golang.org/x/term v0.20.0/go.mod h1:8UkIAJTvZgivsXaD6/pH6U9ecQzZ45awqEOzuCvwpFY= golang.org/x/term v0.21.0/go.mod h1:ooXLefLobQVslOqselCNF4SxFAaoS6KujMbsGzSDmX0= @@ -304,6 +320,8 @@ golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8T gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/inconshreveable/log15.v2 v2.0.0-20180818164646-67afb5ed74ec/go.mod h1:aPpfJ7XW+gOuirDoZ8gHhLh3kZ1B08FtV2bbmy7Jv3s= gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22 h1:VpOs+IwYnYBaFnrNAeB8UUWtL3vEUnzSCL1nVjPhqrw= diff --git a/internal/testsuite/generic_suite.go b/internal/testsuite/generic_suite.go index 5cbcc1d0..98832a61 100644 --- a/internal/testsuite/generic_suite.go +++ b/internal/testsuite/generic_suite.go @@ -133,6 +133,7 @@ func (s *GenericTestSuite) TestDatesAndUnicode() { sess := s.Session() testTimeZone := time.Local + switch s.Adapter() { case "mysql", "cockroachdb", "postgresql": testTimeZone = defaultTimeLocation From d51a71abd8b283e4947f8e0cdf3e15d65414fa9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Nieto?= Date: Sun, 25 Aug 2024 18:57:51 -0600 Subject: [PATCH 2/2] add test for inet value --- adapter/postgresql/Makefile | 2 +- adapter/postgresql/helper_test.go | 2 +- adapter/postgresql/postgresql_test.go | 3 +++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/adapter/postgresql/Makefile b/adapter/postgresql/Makefile index 162ffdd4..a751cd4c 100644 --- a/adapter/postgresql/Makefile +++ b/adapter/postgresql/Makefile @@ -11,7 +11,7 @@ DB_NAME ?= upperio DB_USERNAME ?= upperio_user DB_PASSWORD ?= upperio//s3cr37 -TEST_FLAGS ?= +TEST_FLAGS ?= -v -failfast PARALLEL_FLAGS ?= --halt-on-error 2 --jobs 1 export POSTGRES_VERSION diff --git a/adapter/postgresql/helper_test.go b/adapter/postgresql/helper_test.go index 5d565aef..6f2dbfa6 100644 --- a/adapter/postgresql/helper_test.go +++ b/adapter/postgresql/helper_test.go @@ -239,7 +239,7 @@ func (h *Helper) TearUp() error { , decimal_value_ptr decimal , uuid_value_string UUID - + , ip_addr_ptr inet null )`, `DROP TABLE IF EXISTS issue_370`, diff --git a/adapter/postgresql/postgresql_test.go b/adapter/postgresql/postgresql_test.go index 182352b5..ec56d583 100644 --- a/adapter/postgresql/postgresql_test.go +++ b/adapter/postgresql/postgresql_test.go @@ -28,6 +28,7 @@ import ( "encoding/json" "fmt" "math/rand" + "net" "strings" "sync" "testing" @@ -266,6 +267,8 @@ func testPostgreSQLTypes(t *testing.T, sess db.Session) { DecimalValuePtr *float64 `db:"decimal_value_ptr,omitempty"` UUIDValueString *string `db:"uuid_value_string,omitempty"` + + IPAddrPtr *net.IPNet `db:"ip_addr_ptr,omitempty"` } integerValue := int64(10)