Skip to content

Commit

Permalink
uuid extension switched to gofrs from satori
Browse files Browse the repository at this point in the history
Do not encourage library use that has serious outstanding bug:
satori/go.uuid#73
  • Loading branch information
jackc committed Sep 15, 2019
1 parent a8802b1 commit cf8fe4a
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 13 deletions.
2 changes: 1 addition & 1 deletion ext/satori-uuid/uuid.go → ext/gofrs-uuid/uuid.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (

errors "golang.org/x/xerrors"

"github.com/gofrs/uuid"
"github.com/jackc/pgtype"
uuid "github.com/satori/go.uuid"
)

var errUndefined = errors.New("cannot encode status undefined")
Expand Down
22 changes: 11 additions & 11 deletions ext/satori-uuid/uuid_test.go → ext/gofrs-uuid/uuid_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,38 +5,38 @@ import (
"testing"

"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"
)

func TestUUIDTranscode(t *testing.T) {
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},
&satori.UUID{Status: pgtype.Null},
&gofrs.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{Status: pgtype.Null},
})
}

func TestUUIDSet(t *testing.T) {
successfulTests := []struct {
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},
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},
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",
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 {
var r satori.UUID
var r gofrs.UUID
err := r.Set(tt.source)
if err != nil {
t.Errorf("%d: %v", i, err)
Expand All @@ -50,7 +50,7 @@ func TestUUIDSet(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
expected := [16]byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}

Expand All @@ -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
expected := []byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}

Expand All @@ -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
expected := "00010203-0405-0607-0809-0a0b0c0d0e0f"

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ module github.com/jackc/pgtype
go 1.12

require (
github.com/gofrs/uuid v3.2.0+incompatible
github.com/jackc/pgio v1.0.0
github.com/jackc/pgx/v4 v4.0.0-pre1.0.20190824185557-6972a5742186
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/stretchr/testify v1.4.0
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
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/go.mod h1:RT6O25fNZIuasFJRyZ4R/Y2BbhasbmZXF9QQ7T3kePo=
github.com/jackc/chunkreader/v2 v2.0.0 h1:DUwgMQuuPnS0rhMXenUtZpqZqrR/30NWY+qQvTpSvEs=
Expand Down

0 comments on commit cf8fe4a

Please sign in to comment.