Fixed import paths for null package, add byte typ
This commit is contained in:
parent
3d22dc0897
commit
86ca3bbcea
8 changed files with 47 additions and 26 deletions
|
@ -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":
|
||||
|
|
34
imports.go
34
imports.go
|
@ -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"`},
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ import (
|
|||
"testing"
|
||||
"time"
|
||||
|
||||
"gopkg.in/nullbio/null.v5"
|
||||
null "gopkg.in/nullbio/null.v6"
|
||||
)
|
||||
|
||||
type testObj struct {
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -5,7 +5,7 @@ import (
|
|||
"testing"
|
||||
"time"
|
||||
|
||||
"gopkg.in/nullbio/null.v5"
|
||||
null "gopkg.in/nullbio/null.v6"
|
||||
)
|
||||
|
||||
func TestRandomizeStruct(t *testing.T) {
|
||||
|
|
|
@ -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(", ")
|
||||
}
|
||||
|
|
17
testdata/postgres_test_schema.sql
vendored
17
testdata/postgres_test_schema.sql
vendored
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue