Skip to content

Commit

Permalink
Remove dependency in randomize interface
Browse files Browse the repository at this point in the history
The `seed` type was forcing a dependency on sqlboiler, which was pretty
poor form for an interface. Instead now we just pass in a function that
allows us to create integers.

- Change `seed` parameter to `func() int64` in Randomizer
- Stop using gopkg.in for versioning the null package
  • Loading branch information
aarondl committed Jul 4, 2018
1 parent 7c76df8 commit 84770d2
Show file tree
Hide file tree
Showing 30 changed files with 201 additions and 218 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
sidestep viper's constant downcasing of config keys. This is the
exact same fix as happened with aliases previously.

### Changed

- Change the `seed` parameter to a `func () int64` function that when called
safely produces a new thread-safe pseudorandom sequential integer. This was
done to remove the dependency on `sqlboiler` code.
- Stop using gopkg.in for versioning for the null package. Please ensure you
have null package v8.0.0 or higher after this change.

### Fixed

- Remove generation disclaimer for non-go files which prevents proper parsing
Expand Down
8 changes: 4 additions & 4 deletions drivers/mocks/mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@ func (m *MockDriver) Imports() (importers.Collection, error) {
return importers.Collection{
BasedOnType: importers.Map{
"null.Int": {
ThirdParty: importers.List{`"gopkg.in/volatiletech/null.v7"`},
ThirdParty: importers.List{`"github.com/volatiletech/null"`},
},
"null.String": {
ThirdParty: importers.List{`"gopkg.in/volatiletech/null.v7"`},
ThirdParty: importers.List{`"github.com/volatiletech/null"`},
},
"null.Time": {
ThirdParty: importers.List{`"gopkg.in/volatiletech/null.v7"`},
ThirdParty: importers.List{`"github.com/volatiletech/null"`},
},
"null.Bytes": {
ThirdParty: importers.List{`"gopkg.in/volatiletech/null.v7"`},
ThirdParty: importers.List{`"github.com/volatiletech/null"`},
},

"time.Time": {
Expand Down
32 changes: 16 additions & 16 deletions drivers/sqlboiler-mssql/driver/mssql.go
Original file line number Diff line number Diff line change
Expand Up @@ -486,52 +486,52 @@ func (MSSQLDriver) Imports() (col importers.Collection, err error) {

col.BasedOnType = importers.Map{
"null.Float32": {
ThirdParty: importers.List{`"gopkg.in/volatiletech/null.v7"`},
ThirdParty: importers.List{`"github.com/volatiletech/null"`},
},
"null.Float64": {
ThirdParty: importers.List{`"gopkg.in/volatiletech/null.v7"`},
ThirdParty: importers.List{`"github.com/volatiletech/null"`},
},
"null.Int": {
ThirdParty: importers.List{`"gopkg.in/volatiletech/null.v7"`},
ThirdParty: importers.List{`"github.com/volatiletech/null"`},
},
"null.Int8": {
ThirdParty: importers.List{`"gopkg.in/volatiletech/null.v7"`},
ThirdParty: importers.List{`"github.com/volatiletech/null"`},
},
"null.Int16": {
ThirdParty: importers.List{`"gopkg.in/volatiletech/null.v7"`},
ThirdParty: importers.List{`"github.com/volatiletech/null"`},
},
"null.Int32": {
ThirdParty: importers.List{`"gopkg.in/volatiletech/null.v7"`},
ThirdParty: importers.List{`"github.com/volatiletech/null"`},
},
"null.Int64": {
ThirdParty: importers.List{`"gopkg.in/volatiletech/null.v7"`},
ThirdParty: importers.List{`"github.com/volatiletech/null"`},
},
"null.Uint": {
ThirdParty: importers.List{`"gopkg.in/volatiletech/null.v7"`},
ThirdParty: importers.List{`"github.com/volatiletech/null"`},
},
"null.Uint8": {
ThirdParty: importers.List{`"gopkg.in/volatiletech/null.v7"`},
ThirdParty: importers.List{`"github.com/volatiletech/null"`},
},
"null.Uint16": {
ThirdParty: importers.List{`"gopkg.in/volatiletech/null.v7"`},
ThirdParty: importers.List{`"github.com/volatiletech/null"`},
},
"null.Uint32": {
ThirdParty: importers.List{`"gopkg.in/volatiletech/null.v7"`},
ThirdParty: importers.List{`"github.com/volatiletech/null"`},
},
"null.Uint64": {
ThirdParty: importers.List{`"gopkg.in/volatiletech/null.v7"`},
ThirdParty: importers.List{`"github.com/volatiletech/null"`},
},
"null.String": {
ThirdParty: importers.List{`"gopkg.in/volatiletech/null.v7"`},
ThirdParty: importers.List{`"github.com/volatiletech/null"`},
},
"null.Bool": {
ThirdParty: importers.List{`"gopkg.in/volatiletech/null.v7"`},
ThirdParty: importers.List{`"github.com/volatiletech/null"`},
},
"null.Time": {
ThirdParty: importers.List{`"gopkg.in/volatiletech/null.v7"`},
ThirdParty: importers.List{`"github.com/volatiletech/null"`},
},
"null.Bytes": {
ThirdParty: importers.List{`"gopkg.in/volatiletech/null.v7"`},
ThirdParty: importers.List{`"github.com/volatiletech/null"`},
},
"time.Time": {
Standard: importers.List{`"time"`},
Expand Down
32 changes: 16 additions & 16 deletions drivers/sqlboiler-mysql/driver/mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -506,52 +506,52 @@ func (MySQLDriver) Imports() (col importers.Collection, err error) {

col.BasedOnType = importers.Map{
"null.Float32": {
ThirdParty: importers.List{`"gopkg.in/volatiletech/null.v7"`},
ThirdParty: importers.List{`"github.com/volatiletech/null"`},
},
"null.Float64": {
ThirdParty: importers.List{`"gopkg.in/volatiletech/null.v7"`},
ThirdParty: importers.List{`"github.com/volatiletech/null"`},
},
"null.Int": {
ThirdParty: importers.List{`"gopkg.in/volatiletech/null.v7"`},
ThirdParty: importers.List{`"github.com/volatiletech/null"`},
},
"null.Int8": {
ThirdParty: importers.List{`"gopkg.in/volatiletech/null.v7"`},
ThirdParty: importers.List{`"github.com/volatiletech/null"`},
},
"null.Int16": {
ThirdParty: importers.List{`"gopkg.in/volatiletech/null.v7"`},
ThirdParty: importers.List{`"github.com/volatiletech/null"`},
},
"null.Int32": {
ThirdParty: importers.List{`"gopkg.in/volatiletech/null.v7"`},
ThirdParty: importers.List{`"github.com/volatiletech/null"`},
},
"null.Int64": {
ThirdParty: importers.List{`"gopkg.in/volatiletech/null.v7"`},
ThirdParty: importers.List{`"github.com/volatiletech/null"`},
},
"null.Uint": {
ThirdParty: importers.List{`"gopkg.in/volatiletech/null.v7"`},
ThirdParty: importers.List{`"github.com/volatiletech/null"`},
},
"null.Uint8": {
ThirdParty: importers.List{`"gopkg.in/volatiletech/null.v7"`},
ThirdParty: importers.List{`"github.com/volatiletech/null"`},
},
"null.Uint16": {
ThirdParty: importers.List{`"gopkg.in/volatiletech/null.v7"`},
ThirdParty: importers.List{`"github.com/volatiletech/null"`},
},
"null.Uint32": {
ThirdParty: importers.List{`"gopkg.in/volatiletech/null.v7"`},
ThirdParty: importers.List{`"github.com/volatiletech/null"`},
},
"null.Uint64": {
ThirdParty: importers.List{`"gopkg.in/volatiletech/null.v7"`},
ThirdParty: importers.List{`"github.com/volatiletech/null"`},
},
"null.String": {
ThirdParty: importers.List{`"gopkg.in/volatiletech/null.v7"`},
ThirdParty: importers.List{`"github.com/volatiletech/null"`},
},
"null.Bool": {
ThirdParty: importers.List{`"gopkg.in/volatiletech/null.v7"`},
ThirdParty: importers.List{`"github.com/volatiletech/null"`},
},
"null.Time": {
ThirdParty: importers.List{`"gopkg.in/volatiletech/null.v7"`},
ThirdParty: importers.List{`"github.com/volatiletech/null"`},
},
"null.Bytes": {
ThirdParty: importers.List{`"gopkg.in/volatiletech/null.v7"`},
ThirdParty: importers.List{`"github.com/volatiletech/null"`},
},

"time.Time": {
Expand Down
34 changes: 17 additions & 17 deletions drivers/sqlboiler-psql/driver/psql.go
Original file line number Diff line number Diff line change
Expand Up @@ -586,55 +586,55 @@ func (p PostgresDriver) Imports() (importers.Collection, error) {
}
col.BasedOnType = importers.Map{
"null.Float32": {
ThirdParty: importers.List{`"gopkg.in/volatiletech/null.v7"`},
ThirdParty: importers.List{`"github.com/volatiletech/null"`},
},
"null.Float64": {
ThirdParty: importers.List{`"gopkg.in/volatiletech/null.v7"`},
ThirdParty: importers.List{`"github.com/volatiletech/null"`},
},
"null.Int": {
ThirdParty: importers.List{`"gopkg.in/volatiletech/null.v7"`},
ThirdParty: importers.List{`"github.com/volatiletech/null"`},
},
"null.Int8": {
ThirdParty: importers.List{`"gopkg.in/volatiletech/null.v7"`},
ThirdParty: importers.List{`"github.com/volatiletech/null"`},
},
"null.Int16": {
ThirdParty: importers.List{`"gopkg.in/volatiletech/null.v7"`},
ThirdParty: importers.List{`"github.com/volatiletech/null"`},
},
"null.Int32": {
ThirdParty: importers.List{`"gopkg.in/volatiletech/null.v7"`},
ThirdParty: importers.List{`"github.com/volatiletech/null"`},
},
"null.Int64": {
ThirdParty: importers.List{`"gopkg.in/volatiletech/null.v7"`},
ThirdParty: importers.List{`"github.com/volatiletech/null"`},
},
"null.Uint": {
ThirdParty: importers.List{`"gopkg.in/volatiletech/null.v7"`},
ThirdParty: importers.List{`"github.com/volatiletech/null"`},
},
"null.Uint8": {
ThirdParty: importers.List{`"gopkg.in/volatiletech/null.v7"`},
ThirdParty: importers.List{`"github.com/volatiletech/null"`},
},
"null.Uint16": {
ThirdParty: importers.List{`"gopkg.in/volatiletech/null.v7"`},
ThirdParty: importers.List{`"github.com/volatiletech/null"`},
},
"null.Uint32": {
ThirdParty: importers.List{`"gopkg.in/volatiletech/null.v7"`},
ThirdParty: importers.List{`"github.com/volatiletech/null"`},
},
"null.Uint64": {
ThirdParty: importers.List{`"gopkg.in/volatiletech/null.v7"`},
ThirdParty: importers.List{`"github.com/volatiletech/null"`},
},
"null.String": {
ThirdParty: importers.List{`"gopkg.in/volatiletech/null.v7"`},
ThirdParty: importers.List{`"github.com/volatiletech/null"`},
},
"null.Bool": {
ThirdParty: importers.List{`"gopkg.in/volatiletech/null.v7"`},
ThirdParty: importers.List{`"github.com/volatiletech/null"`},
},
"null.Time": {
ThirdParty: importers.List{`"gopkg.in/volatiletech/null.v7"`},
ThirdParty: importers.List{`"github.com/volatiletech/null"`},
},
"null.JSON": {
ThirdParty: importers.List{`"gopkg.in/volatiletech/null.v7"`},
ThirdParty: importers.List{`"github.com/volatiletech/null"`},
},
"null.Bytes": {
ThirdParty: importers.List{`"gopkg.in/volatiletech/null.v7"`},
ThirdParty: importers.List{`"github.com/volatiletech/null"`},
},
"time.Time": {
Standard: importers.List{`"time"`},
Expand Down
12 changes: 6 additions & 6 deletions importers/imports_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,8 @@ func TestAddTypeImports(t *testing.T) {
`"time"`,
},
ThirdParty: List{
`"github.com/volatiletech/null"`,
`"github.com/volatiletech/sqlboiler/boil"`,
`"gopkg.in/volatiletech/null.v7"`,
},
}

Expand All @@ -200,7 +200,7 @@ func TestAddTypeImports(t *testing.T) {
imps := NewDefaultImports()

imps.BasedOnType = Map{
"null.Time": Set{ThirdParty: List{`"gopkg.in/volatiletech/null.v7"`}},
"null.Time": Set{ThirdParty: List{`"github.com/volatiletech/null"`}},
"time.Time": Set{Standard: List{`"time"`}},
}

Expand All @@ -217,8 +217,8 @@ func TestAddTypeImports(t *testing.T) {
`"time"`,
},
ThirdParty: List{
`"github.com/volatiletech/null"`,
`"github.com/volatiletech/sqlboiler/boil"`,
`"gopkg.in/volatiletech/null.v7"`,
},
}

Expand All @@ -234,7 +234,7 @@ func TestMergeSet(t *testing.T) {

a := Set{
Standard: List{"fmt"},
ThirdParty: List{"github.com/volatiletech/sqlboiler", "gopkg.in/nullbio/null.v7"},
ThirdParty: List{"github.com/volatiletech/sqlboiler", "github.com/volatiletech/null"},
}
b := Set{
Standard: List{"os"},
Expand All @@ -246,8 +246,8 @@ func TestMergeSet(t *testing.T) {
if c.Standard[0] != "fmt" && c.Standard[1] != "os" {
t.Errorf("Wanted: fmt, os got: %#v", c.Standard)
}
if c.ThirdParty[0] != "github.com/volatiletech/sqlboiler" && c.ThirdParty[1] != "gopkg.in/nullbio/null.v7" {
t.Errorf("Wanted: github.com/volatiletech/sqlboiler, gopkg.in/nullbio/null.v7 got: %#v", c.ThirdParty)
if c.ThirdParty[0] != "github.com/volatiletech/null" && c.ThirdParty[1] != "github.com/volatiletech/sqlboiler" {
t.Errorf("Wanted: github.com/volatiletech/sqlboiler, github.com/volatiletech/null got: %#v", c.ThirdParty)
}
}

Expand Down
2 changes: 1 addition & 1 deletion queries/helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"testing"
"time"

null "gopkg.in/volatiletech/null.v7"
"github.com/volatiletech/null"
)

type testObj struct {
Expand Down
Loading

0 comments on commit 84770d2

Please sign in to comment.