Fixed import paths for null package, add byte typ

This commit is contained in:
Patrick O'brien 2016-11-12 12:02:44 +10:00
parent 3d22dc0897
commit 86ca3bbcea
8 changed files with 47 additions and 26 deletions

View file

@ -317,6 +317,8 @@ func (p *PostgresDriver) TranslateColumnType(c bdb.Column) bdb.Column {
c.Type = "null.Float32"
case "bit", "interval", "bit varying", "character", "money", "character varying", "cidr", "inet", "macaddr", "text", "uuid", "xml":
c.Type = "null.String"
case `"char"`:
c.Type = "null.Byte"
case "bytea":
c.Type = "null.Bytes"
case "json", "jsonb":
@ -357,6 +359,8 @@ func (p *PostgresDriver) TranslateColumnType(c bdb.Column) bdb.Column {
c.Type = "float32"
case "bit", "interval", "uuint", "bit varying", "character", "money", "character varying", "cidr", "inet", "macaddr", "text", "uuid", "xml":
c.Type = "string"
case `"char"`:
c.Type = "types.Byte"
case "json", "jsonb":
c.Type = "types.JSON"
case "bytea":

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -380,7 +380,7 @@ func MakeStringMap(types map[string]string) string {
c := 0
for _, k := range keys {
v := types[k]
buf.WriteString(fmt.Sprintf(`"%s": "%s"`, k, v))
buf.WriteString(fmt.Sprintf("`%s`: `%s`", k, v))
if c < len(types)-1 {
buf.WriteString(", ")
}

View file

@ -24,6 +24,23 @@ CREATE TABLE magic (
string_ten VARCHAR(1000) NULL DEFAULT '',
string_eleven VARCHAR(1000) NOT NULL DEFAULT '',
nonbyte_zero CHAR(1),
nonbyte_one CHAR(1) NULL,
nonbyte_two CHAR(1) NOT NULL,
nonbyte_three CHAR(1) NULL DEFAULT 'a',
nonbyte_four CHAR(1) NOT NULL DEFAULT 'b',
nonbyte_five CHAR(1000),
nonbyte_six CHAR(1000) NULL,
nonbyte_seven CHAR(1000) NOT NULL,
nonbyte_eight CHAR(1000) NULL DEFAULT 'a',
nonbyte_nine CHAR(1000) NOT NULL DEFAULT 'b',
byte_zero "char",
byte_one "char" NULL,
byte_two "char" NOT NULL,
byte_three "char" NULL DEFAULT 'a',
byte_four "char" NOT NULL DEFAULT 'b',
big_int_zero bigint,
big_int_one bigint NULL,
big_int_two bigint NOT NULL,