Skip to content

Commit

Permalink
Merge pull request #3 from vgarvardt/bump-pgx
Browse files Browse the repository at this point in the history
Use latest pgx version and use any insteaf of interface
  • Loading branch information
vgarvardt authored May 6, 2022
2 parents 7685e4f + d37848e commit ce0ffec
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 19 deletions.
9 changes: 3 additions & 6 deletions Taskfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,15 @@ tasks:
test:
summary: Run tests
cmds:
- task: ensure-docker-compose-version
- task: test-deps-up
- task: test-run
- task: test-deps-down

ensure-docker-compose-version:
summary: Ensures that docker-compose is v2
cmds:
- cmd: docker-compose version --short | grep '^2'

test-deps-up:
summary: Starts test dependencies
preconditions:
- sh: docker-compose version --short | grep '^2'
msg: "docker-compose v2 is expected to be installed"
cmds:
- cmd: docker-compose up --detach --wait

Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.18

require (
github.com/google/uuid v1.3.0
github.com/jackc/pgx/v5 v5.0.0-alpha.2
github.com/jackc/pgx/v5 v5.0.0-alpha.3
github.com/stretchr/testify v1.7.1
)

Expand All @@ -14,7 +14,7 @@ require (
github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b // indirect
github.com/kr/text v0.1.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
golang.org/x/crypto v0.0.0-20211209193657-4570a0811e8b // indirect
golang.org/x/crypto v0.0.0-20220427172511-eb4f295cb31f // indirect
golang.org/x/text v0.3.7 // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
)
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsI
github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg=
github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b h1:C8S2+VttkHFdOOCXJe+YGfa4vHYwlt4Zx+IVXQ97jYg=
github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b/go.mod h1:vsD4gTJCa9TptPL8sPkXrLZ+hDuNrZCnj29CQpr4X1E=
github.com/jackc/pgx/v5 v5.0.0-alpha.2 h1:cf4s9vStsVVwE+bAWSswlcAtU4oHRkU+P/TfpWTUR9k=
github.com/jackc/pgx/v5 v5.0.0-alpha.2/go.mod h1:hpqr/HW4qanKY/8S2BFVFWYaOpch/IjnvAAt6YdntZQ=
github.com/jackc/pgx/v5 v5.0.0-alpha.3 h1:GIKi4W8Nz6oiYfHWW761iLi2iFiRo2fZ+L8h2SzCYpk=
github.com/jackc/pgx/v5 v5.0.0-alpha.3/go.mod h1:9166s9MdYYheYgI0ySjd/tbPF4wbq4vjgVzkZSt2UDE=
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
Expand All @@ -20,8 +20,8 @@ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UV
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
github.com/stretchr/testify v1.7.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMTY=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
golang.org/x/crypto v0.0.0-20211209193657-4570a0811e8b h1:QAqMVf3pSa6eeTsuklijukjXBlj7Es2QQplab+/RbQ4=
golang.org/x/crypto v0.0.0-20211209193657-4570a0811e8b/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.0.0-20220427172511-eb4f295cb31f h1:OeJjE6G4dgCY4PIXvIRQbE8+RX+uXZyGhUy/ksMGJoc=
golang.org/x/crypto v0.0.0-20220427172511-eb4f295cb31f/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
Expand Down
14 changes: 7 additions & 7 deletions uuid.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func (u NullUUID) UUIDValue() (pgtype.UUID, error) {
}

// TryWrapUUIDEncodePlan implements pgtype.TryWrapEncodePlanFunc interface
func TryWrapUUIDEncodePlan(value interface{}) (plan pgtype.WrappedEncodePlanNextSetter, nextValue interface{}, ok bool) {
func TryWrapUUIDEncodePlan(value any) (plan pgtype.WrappedEncodePlanNextSetter, nextValue any, ok bool) {
switch value := value.(type) {
case uuid.UUID:
return &wrapUUIDEncodePlan{}, UUID(value), true
Expand All @@ -59,7 +59,7 @@ type wrapUUIDEncodePlan struct {
func (plan *wrapUUIDEncodePlan) SetNext(next pgtype.EncodePlan) { plan.next = next }

// Encode implements pgtype.EncodePlan interface
func (plan *wrapUUIDEncodePlan) Encode(value interface{}, buf []byte) (newBuf []byte, err error) {
func (plan *wrapUUIDEncodePlan) Encode(value any, buf []byte) (newBuf []byte, err error) {
return plan.next.Encode(UUID(value.(uuid.UUID)), buf)
}

Expand All @@ -71,12 +71,12 @@ type wrapNullUUIDEncodePlan struct {
func (plan *wrapNullUUIDEncodePlan) SetNext(next pgtype.EncodePlan) { plan.next = next }

// Encode implements pgtype.EncodePlan interface
func (plan *wrapNullUUIDEncodePlan) Encode(value interface{}, buf []byte) (newBuf []byte, err error) {
func (plan *wrapNullUUIDEncodePlan) Encode(value any, buf []byte) (newBuf []byte, err error) {
return plan.next.Encode(NullUUID(value.(uuid.NullUUID)), buf)
}

// TryWrapUUIDScanPlan implements pgtype.TryWrapScanPlanFunc
func TryWrapUUIDScanPlan(target interface{}) (plan pgtype.WrappedScanPlanNextSetter, nextDst interface{}, ok bool) {
func TryWrapUUIDScanPlan(target any) (plan pgtype.WrappedScanPlanNextSetter, nextDst any, ok bool) {
switch target := target.(type) {
case *uuid.UUID:
return &wrapUUIDScanPlan{}, (*UUID)(target), true
Expand All @@ -95,7 +95,7 @@ type wrapUUIDScanPlan struct {
func (plan *wrapUUIDScanPlan) SetNext(next pgtype.ScanPlan) { plan.next = next }

// Scan implements pgtype.ScanPlan interface
func (plan *wrapUUIDScanPlan) Scan(src []byte, dst interface{}) error {
func (plan *wrapUUIDScanPlan) Scan(src []byte, dst any) error {
return plan.next.Scan(src, (*UUID)(dst.(*uuid.UUID)))
}

Expand All @@ -107,7 +107,7 @@ type wrapNullUUIDScanPlan struct {
func (plan *wrapNullUUIDScanPlan) SetNext(next pgtype.ScanPlan) { plan.next = next }

// Scan implements pgtype.ScanPlan interface
func (plan *wrapNullUUIDScanPlan) Scan(src []byte, dst interface{}) error {
func (plan *wrapNullUUIDScanPlan) Scan(src []byte, dst any) error {
return plan.next.Scan(src, (*NullUUID)(dst.(*uuid.NullUUID)))
}

Expand All @@ -118,7 +118,7 @@ type UUIDCodec struct {
}

// DecodeValue implements pgtype.Codec interface
func (UUIDCodec) DecodeValue(tm *pgtype.Map, oid uint32, format int16, src []byte) (interface{}, error) {
func (UUIDCodec) DecodeValue(tm *pgtype.Map, oid uint32, format int16, src []byte) (any, error) {
if src == nil {
return nil, nil
}
Expand Down
1 change: 1 addition & 0 deletions uuid_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/jackc/pgx/v5"
"github.com/jackc/pgx/v5/pgxtest"
"github.com/stretchr/testify/require"

pgxuuid "github.com/vgarvardt/pgx-google-uuid/v5"
)

Expand Down

0 comments on commit ce0ffec

Please sign in to comment.