diff --git a/bdb/drivers/postgres.go b/bdb/drivers/postgres.go index e992299..0422939 100644 --- a/bdb/drivers/postgres.go +++ b/bdb/drivers/postgres.go @@ -307,7 +307,7 @@ func (p *PostgresDriver) TranslateColumnType(c bdb.Column) bdb.Column { c.DBType = c.DBType + *c.ArrType case "USER-DEFINED": if c.UDTName == "hstore" { - c.Type = "types.Hstore" + c.Type = "types.HStore" c.DBType = "hstore" } else { c.Type = "string" @@ -344,7 +344,7 @@ func (p *PostgresDriver) TranslateColumnType(c bdb.Column) bdb.Column { c.DBType = c.DBType + *c.ArrType case "USER-DEFINED": if c.UDTName == "hstore" { - c.Type = "types.Hstore" + c.Type = "types.HStore" c.DBType = "hstore" } else { c.Type = "string" diff --git a/randomize/randomize.go b/randomize/randomize.go index 3f5ae29..7391980 100644 --- a/randomize/randomize.go +++ b/randomize/randomize.go @@ -14,7 +14,6 @@ import ( "gopkg.in/nullbio/null.v5" - "github.com/lib/pq/hstore" "github.com/pkg/errors" "github.com/satori/go.uuid" "github.com/vattle/sqlboiler/strmangle" @@ -46,7 +45,7 @@ var ( typeBoolArray = reflect.TypeOf(types.BoolArray{}) typeFloat64Array = reflect.TypeOf(types.Float64Array{}) typeStringArray = reflect.TypeOf(types.StringArray{}) - typeHstore = reflect.TypeOf(types.Hstore{}) + typeHStore = reflect.TypeOf(types.HStore{}) rgxValidTime = regexp.MustCompile(`[2-9]+`) 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) field.Set(reflect.ValueOf(value)) return nil - case typeHstore: - value := hstore.Hstore{Map: map[string]sql.NullString{}} - value.Map[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} + case typeHStore: + 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} field.Set(reflect.ValueOf(value)) 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))) field.Set(reflect.ValueOf(value)) return nil - case typeHstore: - value := types.Hstore{} + case typeHStore: + 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} field.Set(reflect.ValueOf(value)) diff --git a/types/hstore.go b/types/hstore.go index 6d642c8..101a4f1 100644 --- a/types/hstore.go +++ b/types/hstore.go @@ -25,8 +25,8 @@ import ( "strings" ) -// Hstore is a wrapper for transferring Hstore values back and forth easily. -type Hstore map[string]sql.NullString +// HStore is a wrapper for transferring HStore values back and forth easily. +type HStore map[string]sql.NullString // escapes and quotes hstore keys/values // 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 // 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 { h = 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 // 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 { return nil, nil }