diff --git a/go.mod b/go.mod index 8707040..23d0e07 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.22 // used by jet generator require ( - github.com/go-sql-driver/mysql v1.8.1 + github.com/go-sql-driver/mysql v1.9.0 github.com/google/uuid v1.6.0 github.com/jackc/pgconn v1.14.3 github.com/jackc/pgtype v1.14.4 @@ -15,7 +15,7 @@ require ( // used in tests require ( - github.com/google/go-cmp v0.6.0 + github.com/google/go-cmp v0.7.0 github.com/pkg/profile v1.7.0 github.com/shopspring/decimal v1.4.0 github.com/stretchr/testify v1.10.0 diff --git a/go.sum b/go.sum index 72c0584..5f5b0f8 100644 --- a/go.sum +++ b/go.sum @@ -20,14 +20,14 @@ github.com/friendsofgo/errors v0.9.2 h1:X6NYxef4efCBdwI7BgS820zFaN7Cphrmb+Pljdzj github.com/friendsofgo/errors v0.9.2/go.mod h1:yCvFW5AkDIL9qn7suHVLiI/gH228n7PC4Pn44IGoTOI= github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY= github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= -github.com/go-sql-driver/mysql v1.8.1 h1:LedoTUt/eveggdHS9qUFC1EFSa8bU2+1pZjSRpvNJ1Y= -github.com/go-sql-driver/mysql v1.8.1/go.mod h1:wEBSXgmK//2ZFJyE+qWnIsVGmvmEKlqwuVSjsCm7DZg= +github.com/go-sql-driver/mysql v1.9.0 h1:Y0zIbQXhQKmQgTp44Y1dp3wTXcn804QoTptLZT1vtvo= +github.com/go-sql-driver/mysql v1.9.0/go.mod h1:pDetrLJeA3oMujJuvXc8RJoasr589B6A9fwzD3QMrqw= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/gofrs/uuid v3.2.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= github.com/gofrs/uuid v4.0.0+incompatible h1:1SD/1F5pU8p29ybwgQSwpQk+mwdRrXCYuPhW6m+TnJw= github.com/gofrs/uuid v4.0.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= -github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= -github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= +github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/google/pprof v0.0.0-20211214055906-6f57359322fd h1:1FjCyPC+syAzJ5/2S8fqdZK1R22vvA0J7JZKcuOIQ7Y= github.com/google/pprof v0.0.0-20211214055906-6f57359322fd/go.mod h1:KgnwoLYCZ8IQu3XUZ8Nc/bM9CCZFOyjUNOSygVozoDg= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= diff --git a/postgres/literal.go b/postgres/literal.go index e785b48..a6a1618 100644 --- a/postgres/literal.go +++ b/postgres/literal.go @@ -49,6 +49,11 @@ func Uint32(value uint32) IntegerExpression { return CAST(jet.Uint32(value)).AS_BIGINT() } +// Uint64 is constructor for 64 bit unsigned integer expressions literals. +func Uint64(value uint64) IntegerExpression { + return CAST(jet.Uint64(value)).AS_BIGINT() +} + // Float creates new float literal expression var Float = jet.Float diff --git a/postgres/literal_test.go b/postgres/literal_test.go index 7147573..b788098 100644 --- a/postgres/literal_test.go +++ b/postgres/literal_test.go @@ -49,6 +49,11 @@ func TestUint32(t *testing.T) { assertSerialize(t, Uint32(val), `$1::bigint`, val) } +func TestUint64(t *testing.T) { + val := uint32(math.MaxUint32) + assertSerialize(t, Uint32(val), `$1::bigint`, val) +} + func TestFloat(t *testing.T) { assertSerialize(t, Float(12.34), `$1`, float64(12.34)) diff --git a/tests/postgres/alltypes_test.go b/tests/postgres/alltypes_test.go index e564a91..9c4d878 100644 --- a/tests/postgres/alltypes_test.go +++ b/tests/postgres/alltypes_test.go @@ -4,8 +4,9 @@ import ( "encoding/base64" "fmt" "github.com/go-jet/jet/v2/internal/utils/ptr" - "github.com/go-jet/jet/v2/qrm" "github.com/stretchr/testify/assert" + + "github.com/go-jet/jet/v2/qrm" "testing" "time" @@ -1049,6 +1050,18 @@ LIMIT $38; testutils.AssertJSONFile(t, dest, "./testdata/results/common/float_operators.json") } +func TestUInt64Overflow(t *testing.T) { + stmt := AllTypes.INSERT(AllTypes.BigInt). + VALUES(Uint64(math.MaxUint64)) + + _, err := stmt.Exec(db) + if isPgxDriver() { + require.ErrorContains(t, err, "18446744073709551615 is greater than maximum value for Int8") + } else { + require.ErrorContains(t, err, "sql: converting argument $1 type: uint64 values with high bit set are not supported") + } +} + func TestIntegerOperators(t *testing.T) { skipForCockroachDB(t) // some functions are still unimplemented