2
0

uuid extension switched to gofrs from satori

Do not encourage library use that has serious outstanding bug:
https://github.com/satori/go.uuid/issues/73
This commit is contained in:
Jack Christensen
2019-09-14 19:57:32 -05:00
parent a8802b16cc
commit cf8fe4a477
4 changed files with 15 additions and 13 deletions
@@ -5,8 +5,8 @@ import (
errors "golang.org/x/xerrors" errors "golang.org/x/xerrors"
"github.com/gofrs/uuid"
"github.com/jackc/pgtype" "github.com/jackc/pgtype"
uuid "github.com/satori/go.uuid"
) )
var errUndefined = errors.New("cannot encode status undefined") var errUndefined = errors.New("cannot encode status undefined")
@@ -5,38 +5,38 @@ import (
"testing" "testing"
"github.com/jackc/pgtype" "github.com/jackc/pgtype"
satori "github.com/jackc/pgtype/ext/satori-uuid" gofrs "github.com/jackc/pgtype/ext/gofrs-uuid"
"github.com/jackc/pgtype/testutil" "github.com/jackc/pgtype/testutil"
) )
func TestUUIDTranscode(t *testing.T) { func TestUUIDTranscode(t *testing.T) {
testutil.TestSuccessfulTranscode(t, "uuid", []interface{}{ testutil.TestSuccessfulTranscode(t, "uuid", []interface{}{
&satori.UUID{UUID: [16]byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, Status: pgtype.Present}, &gofrs.UUID{UUID: [16]byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, Status: pgtype.Present},
&satori.UUID{Status: pgtype.Null}, &gofrs.UUID{Status: pgtype.Null},
}) })
} }
func TestUUIDSet(t *testing.T) { func TestUUIDSet(t *testing.T) {
successfulTests := []struct { successfulTests := []struct {
source interface{} source interface{}
result satori.UUID result gofrs.UUID
}{ }{
{ {
source: [16]byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, source: [16]byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15},
result: satori.UUID{UUID: [16]byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, Status: pgtype.Present}, result: gofrs.UUID{UUID: [16]byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, Status: pgtype.Present},
}, },
{ {
source: []byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, source: []byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15},
result: satori.UUID{UUID: [16]byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, Status: pgtype.Present}, result: gofrs.UUID{UUID: [16]byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, Status: pgtype.Present},
}, },
{ {
source: "00010203-0405-0607-0809-0a0b0c0d0e0f", source: "00010203-0405-0607-0809-0a0b0c0d0e0f",
result: satori.UUID{UUID: [16]byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, Status: pgtype.Present}, result: gofrs.UUID{UUID: [16]byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, Status: pgtype.Present},
}, },
} }
for i, tt := range successfulTests { for i, tt := range successfulTests {
var r satori.UUID var r gofrs.UUID
err := r.Set(tt.source) err := r.Set(tt.source)
if err != nil { if err != nil {
t.Errorf("%d: %v", i, err) t.Errorf("%d: %v", i, err)
@@ -50,7 +50,7 @@ func TestUUIDSet(t *testing.T) {
func TestUUIDAssignTo(t *testing.T) { func TestUUIDAssignTo(t *testing.T) {
{ {
src := satori.UUID{UUID: [16]byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, Status: pgtype.Present} src := gofrs.UUID{UUID: [16]byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, Status: pgtype.Present}
var dst [16]byte var dst [16]byte
expected := [16]byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15} expected := [16]byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}
@@ -65,7 +65,7 @@ func TestUUIDAssignTo(t *testing.T) {
} }
{ {
src := satori.UUID{UUID: [16]byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, Status: pgtype.Present} src := gofrs.UUID{UUID: [16]byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, Status: pgtype.Present}
var dst []byte var dst []byte
expected := []byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15} expected := []byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}
@@ -80,7 +80,7 @@ func TestUUIDAssignTo(t *testing.T) {
} }
{ {
src := satori.UUID{UUID: [16]byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, Status: pgtype.Present} src := gofrs.UUID{UUID: [16]byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, Status: pgtype.Present}
var dst string var dst string
expected := "00010203-0405-0607-0809-0a0b0c0d0e0f" expected := "00010203-0405-0607-0809-0a0b0c0d0e0f"
+1 -1
View File
@@ -3,10 +3,10 @@ module github.com/jackc/pgtype
go 1.12 go 1.12
require ( require (
github.com/gofrs/uuid v3.2.0+incompatible
github.com/jackc/pgio v1.0.0 github.com/jackc/pgio v1.0.0
github.com/jackc/pgx/v4 v4.0.0-pre1.0.20190824185557-6972a5742186 github.com/jackc/pgx/v4 v4.0.0-pre1.0.20190824185557-6972a5742186
github.com/lib/pq v1.2.0 github.com/lib/pq v1.2.0
github.com/satori/go.uuid v1.2.0
github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24 github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24
github.com/stretchr/testify v1.4.0 github.com/stretchr/testify v1.4.0
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7 golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7
+2
View File
@@ -8,6 +8,8 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= 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= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
github.com/gofrs/uuid v3.2.0+incompatible h1:y12jRkkFxsd7GpqdSZ+/KCs/fJbqpEXSGd4+jfEaewE=
github.com/gofrs/uuid v3.2.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
github.com/jackc/chunkreader v1.0.0 h1:4s39bBR8ByfqH+DKm8rQA3E1LHZWB9XWcrz8fqaZbe0= github.com/jackc/chunkreader v1.0.0 h1:4s39bBR8ByfqH+DKm8rQA3E1LHZWB9XWcrz8fqaZbe0=
github.com/jackc/chunkreader v1.0.0/go.mod h1:RT6O25fNZIuasFJRyZ4R/Y2BbhasbmZXF9QQ7T3kePo= github.com/jackc/chunkreader v1.0.0/go.mod h1:RT6O25fNZIuasFJRyZ4R/Y2BbhasbmZXF9QQ7T3kePo=
github.com/jackc/chunkreader/v2 v2.0.0 h1:DUwgMQuuPnS0rhMXenUtZpqZqrR/30NWY+qQvTpSvEs= github.com/jackc/chunkreader/v2 v2.0.0 h1:DUwgMQuuPnS0rhMXenUtZpqZqrR/30NWY+qQvTpSvEs=