Updated to null.v5, update postgres driver types

This commit is contained in:
Patrick O'brien 2016-09-07 23:50:54 +10:00
parent 41c36cadf3
commit ce8573eccd
7 changed files with 38 additions and 27 deletions

View file

@ -279,9 +279,9 @@ func (p *PostgresDriver) TranslateColumnType(c bdb.Column) bdb.Column {
c.Type = "null.Float64"
case "real":
c.Type = "null.Float32"
case "bit", "interval", "bit varying", "character", "character varying", "cidr", "inet", "json", "macaddr", "text", "uuid", "xml":
case "bit", "interval", "bit varying", "character", "character varying", "cidr", "inet", "macaddr", "text", "uuid", "xml":
c.Type = "null.String"
case "bytea":
case "bytea", "json", "jsonb":
c.Type = "[]byte"
case "boolean":
c.Type = "null.Bool"
@ -302,8 +302,10 @@ func (p *PostgresDriver) TranslateColumnType(c bdb.Column) bdb.Column {
c.Type = "float64"
case "real":
c.Type = "float32"
case "bit", "interval", "uuint", "bit varying", "character", "character varying", "cidr", "inet", "json", "macaddr", "text", "uuid", "xml":
case "bit", "interval", "uuint", "bit varying", "character", "character varying", "cidr", "inet", "macaddr", "text", "uuid", "xml":
c.Type = "string"
case "json", "jsonb":
c.Type = "json.RawMessage"
case "bytea":
c.Type = "[]byte"
case "boolean":

View file

@ -5,7 +5,7 @@ import (
"testing"
"time"
"gopkg.in/nullbio/null.v4"
"gopkg.in/nullbio/null.v5"
)
type testObj struct {

View file

@ -9,7 +9,7 @@ import (
"sync/atomic"
"time"
"gopkg.in/nullbio/null.v4"
"gopkg.in/nullbio/null.v5"
"github.com/pkg/errors"
"github.com/satori/go.uuid"

View file

@ -5,7 +5,7 @@ import (
"testing"
"time"
"gopkg.in/nullbio/null.v4"
"gopkg.in/nullbio/null.v5"
)
func TestRandomizeStruct(t *testing.T) {

View file

@ -9,7 +9,7 @@ import (
"time"
"gopkg.in/DATA-DOG/go-sqlmock.v1"
"gopkg.in/nullbio/null.v4"
"gopkg.in/nullbio/null.v5"
)
func bin64(i uint64) string {

View file

@ -246,51 +246,60 @@ var defaultTestMainImports = map[string]imports{
// TranslateColumnType to see the type assignments.
var importsBasedOnType = map[string]imports{
"null.Float32": {
thirdParty: importList{`"gopkg.in/nullbio/null.v4"`},
thirdParty: importList{`"gopkg.in/nullbio/null.v5"`},
},
"null.Float64": {
thirdParty: importList{`"gopkg.in/nullbio/null.v4"`},
thirdParty: importList{`"gopkg.in/nullbio/null.v5"`},
},
"null.Int": {
thirdParty: importList{`"gopkg.in/nullbio/null.v4"`},
thirdParty: importList{`"gopkg.in/nullbio/null.v5"`},
},
"null.Int8": {
thirdParty: importList{`"gopkg.in/nullbio/null.v4"`},
thirdParty: importList{`"gopkg.in/nullbio/null.v5"`},
},
"null.Int16": {
thirdParty: importList{`"gopkg.in/nullbio/null.v4"`},
thirdParty: importList{`"gopkg.in/nullbio/null.v5"`},
},
"null.Int32": {
thirdParty: importList{`"gopkg.in/nullbio/null.v4"`},
thirdParty: importList{`"gopkg.in/nullbio/null.v5"`},
},
"null.Int64": {
thirdParty: importList{`"gopkg.in/nullbio/null.v4"`},
thirdParty: importList{`"gopkg.in/nullbio/null.v5"`},
},
"null.Uint": {
thirdParty: importList{`"gopkg.in/nullbio/null.v4"`},
thirdParty: importList{`"gopkg.in/nullbio/null.v5"`},
},
"null.Uint8": {
thirdParty: importList{`"gopkg.in/nullbio/null.v4"`},
thirdParty: importList{`"gopkg.in/nullbio/null.v5"`},
},
"null.Uint16": {
thirdParty: importList{`"gopkg.in/nullbio/null.v4"`},
thirdParty: importList{`"gopkg.in/nullbio/null.v5"`},
},
"null.Uint32": {
thirdParty: importList{`"gopkg.in/nullbio/null.v4"`},
thirdParty: importList{`"gopkg.in/nullbio/null.v5"`},
},
"null.Uint64": {
thirdParty: importList{`"gopkg.in/nullbio/null.v4"`},
thirdParty: importList{`"gopkg.in/nullbio/null.v5"`},
},
"null.String": {
thirdParty: importList{`"gopkg.in/nullbio/null.v4"`},
thirdParty: importList{`"gopkg.in/nullbio/null.v5"`},
},
"null.Bool": {
thirdParty: importList{`"gopkg.in/nullbio/null.v4"`},
thirdParty: importList{`"gopkg.in/nullbio/null.v5"`},
},
"null.Time": {
thirdParty: importList{`"gopkg.in/nullbio/null.v4"`},
thirdParty: importList{`"gopkg.in/nullbio/null.v5"`},
},
"null.JSON": {
thirdParty: importList{`"gopkg.in/nullbio/null.v5"`},
},
"null.Bytes": {
thirdParty: importList{`"gopkg.in/nullbio/null.v5"`},
},
"time.Time": {
standard: importList{`"time"`},
},
"json.RawBytes": {
standard: importList{`"encoding/json"`},
},
}

View file

@ -75,7 +75,7 @@ func TestCombineTypeImports(t *testing.T) {
},
thirdParty: importList{
`"github.com/vattle/sqlboiler/boil"`,
`"gopkg.in/nullbio/null.v4"`,
`"gopkg.in/nullbio/null.v5"`,
},
}
@ -108,7 +108,7 @@ func TestCombineTypeImports(t *testing.T) {
},
thirdParty: importList{
`"github.com/vattle/sqlboiler/boil"`,
`"gopkg.in/nullbio/null.v4"`,
`"gopkg.in/nullbio/null.v5"`,
},
}
@ -124,7 +124,7 @@ func TestCombineImports(t *testing.T) {
a := imports{
standard: importList{"fmt"},
thirdParty: importList{"github.com/vattle/sqlboiler", "gopkg.in/nullbio/null.v4"},
thirdParty: importList{"github.com/vattle/sqlboiler", "gopkg.in/nullbio/null.v5"},
}
b := imports{
standard: importList{"os"},
@ -136,8 +136,8 @@ func TestCombineImports(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/vattle/sqlboiler" && c.thirdParty[1] != "gopkg.in/nullbio/null.v4" {
t.Errorf("Wanted: github.com/vattle/sqlboiler, gopkg.in/nullbio/null.v4 got: %#v", c.thirdParty)
if c.thirdParty[0] != "github.com/vattle/sqlboiler" && c.thirdParty[1] != "gopkg.in/nullbio/null.v5" {
t.Errorf("Wanted: github.com/vattle/sqlboiler, gopkg.in/nullbio/null.v5 got: %#v", c.thirdParty)
}
}