Fix hstore naming
This commit is contained in:
parent
c249cf49d0
commit
40ce5838f3
3 changed files with 13 additions and 14 deletions
|
@ -307,7 +307,7 @@ func (p *PostgresDriver) TranslateColumnType(c bdb.Column) bdb.Column {
|
||||||
c.DBType = c.DBType + *c.ArrType
|
c.DBType = c.DBType + *c.ArrType
|
||||||
case "USER-DEFINED":
|
case "USER-DEFINED":
|
||||||
if c.UDTName == "hstore" {
|
if c.UDTName == "hstore" {
|
||||||
c.Type = "types.Hstore"
|
c.Type = "types.HStore"
|
||||||
c.DBType = "hstore"
|
c.DBType = "hstore"
|
||||||
} else {
|
} else {
|
||||||
c.Type = "string"
|
c.Type = "string"
|
||||||
|
@ -344,7 +344,7 @@ func (p *PostgresDriver) TranslateColumnType(c bdb.Column) bdb.Column {
|
||||||
c.DBType = c.DBType + *c.ArrType
|
c.DBType = c.DBType + *c.ArrType
|
||||||
case "USER-DEFINED":
|
case "USER-DEFINED":
|
||||||
if c.UDTName == "hstore" {
|
if c.UDTName == "hstore" {
|
||||||
c.Type = "types.Hstore"
|
c.Type = "types.HStore"
|
||||||
c.DBType = "hstore"
|
c.DBType = "hstore"
|
||||||
} else {
|
} else {
|
||||||
c.Type = "string"
|
c.Type = "string"
|
||||||
|
|
|
@ -14,7 +14,6 @@ import (
|
||||||
|
|
||||||
"gopkg.in/nullbio/null.v5"
|
"gopkg.in/nullbio/null.v5"
|
||||||
|
|
||||||
"github.com/lib/pq/hstore"
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/satori/go.uuid"
|
"github.com/satori/go.uuid"
|
||||||
"github.com/vattle/sqlboiler/strmangle"
|
"github.com/vattle/sqlboiler/strmangle"
|
||||||
|
@ -46,7 +45,7 @@ var (
|
||||||
typeBoolArray = reflect.TypeOf(types.BoolArray{})
|
typeBoolArray = reflect.TypeOf(types.BoolArray{})
|
||||||
typeFloat64Array = reflect.TypeOf(types.Float64Array{})
|
typeFloat64Array = reflect.TypeOf(types.Float64Array{})
|
||||||
typeStringArray = reflect.TypeOf(types.StringArray{})
|
typeStringArray = reflect.TypeOf(types.StringArray{})
|
||||||
typeHstore = reflect.TypeOf(types.Hstore{})
|
typeHStore = reflect.TypeOf(types.HStore{})
|
||||||
rgxValidTime = regexp.MustCompile(`[2-9]+`)
|
rgxValidTime = regexp.MustCompile(`[2-9]+`)
|
||||||
|
|
||||||
validatedTypes = []string{
|
validatedTypes = []string{
|
||||||
|
@ -226,10 +225,10 @@ func randomizeField(s *Seed, field reflect.Value, fieldType string, canBeNull bo
|
||||||
value = null.NewJSON([]byte(fmt.Sprintf(`"%s"`, randStr(s, 1))), true)
|
value = null.NewJSON([]byte(fmt.Sprintf(`"%s"`, randStr(s, 1))), true)
|
||||||
field.Set(reflect.ValueOf(value))
|
field.Set(reflect.ValueOf(value))
|
||||||
return nil
|
return nil
|
||||||
case typeHstore:
|
case typeHStore:
|
||||||
value := hstore.Hstore{Map: map[string]sql.NullString{}}
|
value := types.HStore{}
|
||||||
value.Map[randStr(s, 3)] = sql.NullString{String: randStr(s, 3), Valid: s.nextInt()%3 == 0}
|
value[randStr(s, 3)] = sql.NullString{String: randStr(s, 3), Valid: s.nextInt()%3 == 0}
|
||||||
value.Map[randStr(s, 3)] = sql.NullString{String: randStr(s, 3), Valid: s.nextInt()%3 == 0}
|
value[randStr(s, 3)] = sql.NullString{String: randStr(s, 3), Valid: s.nextInt()%3 == 0}
|
||||||
field.Set(reflect.ValueOf(value))
|
field.Set(reflect.ValueOf(value))
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -294,8 +293,8 @@ func randomizeField(s *Seed, field reflect.Value, fieldType string, canBeNull bo
|
||||||
value = []byte(fmt.Sprintf(`"%s"`, randStr(s, 1)))
|
value = []byte(fmt.Sprintf(`"%s"`, randStr(s, 1)))
|
||||||
field.Set(reflect.ValueOf(value))
|
field.Set(reflect.ValueOf(value))
|
||||||
return nil
|
return nil
|
||||||
case typeHstore:
|
case typeHStore:
|
||||||
value := types.Hstore{}
|
value := types.HStore{}
|
||||||
value[randStr(s, 3)] = sql.NullString{String: randStr(s, 3), Valid: s.nextInt()%3 == 0}
|
value[randStr(s, 3)] = sql.NullString{String: randStr(s, 3), Valid: s.nextInt()%3 == 0}
|
||||||
value[randStr(s, 3)] = sql.NullString{String: randStr(s, 3), Valid: s.nextInt()%3 == 0}
|
value[randStr(s, 3)] = sql.NullString{String: randStr(s, 3), Valid: s.nextInt()%3 == 0}
|
||||||
field.Set(reflect.ValueOf(value))
|
field.Set(reflect.ValueOf(value))
|
||||||
|
|
|
@ -25,8 +25,8 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Hstore is a wrapper for transferring Hstore values back and forth easily.
|
// HStore is a wrapper for transferring HStore values back and forth easily.
|
||||||
type Hstore map[string]sql.NullString
|
type HStore map[string]sql.NullString
|
||||||
|
|
||||||
// escapes and quotes hstore keys/values
|
// escapes and quotes hstore keys/values
|
||||||
// s should be a sql.NullString or string
|
// s should be a sql.NullString or string
|
||||||
|
@ -52,7 +52,7 @@ func hQuote(s interface{}) string {
|
||||||
//
|
//
|
||||||
// Note h is reallocated before the scan to clear existing values. If the
|
// Note h is reallocated before the scan to clear existing values. If the
|
||||||
// hstore column's database value is NULL, then h is set to nil instead.
|
// hstore column's database value is NULL, then h is set to nil instead.
|
||||||
func (h *Hstore) Scan(value interface{}) error {
|
func (h *HStore) Scan(value interface{}) error {
|
||||||
if value == nil {
|
if value == nil {
|
||||||
h = nil
|
h = nil
|
||||||
return nil
|
return nil
|
||||||
|
@ -122,7 +122,7 @@ func (h *Hstore) Scan(value interface{}) error {
|
||||||
|
|
||||||
// Value implements the driver Valuer interface. Note if h is nil, the
|
// Value implements the driver Valuer interface. Note if h is nil, the
|
||||||
// database column value will be set to NULL.
|
// database column value will be set to NULL.
|
||||||
func (h Hstore) Value() (driver.Value, error) {
|
func (h HStore) Value() (driver.Value, error) {
|
||||||
if h == nil {
|
if h == nil {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue