Skip to content

Commit

Permalink
Fix hstore naming
Browse files Browse the repository at this point in the history
  • Loading branch information
nullbio committed Sep 15, 2016
1 parent c249cf4 commit 40ce583
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 14 deletions.
4 changes: 2 additions & 2 deletions bdb/drivers/postgres.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down
15 changes: 7 additions & 8 deletions randomize/randomize.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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))
Expand Down
8 changes: 4 additions & 4 deletions types/hstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit 40ce583

Please sign in to comment.