Skip to content

Commit

Permalink
fixed an issue with []*SomeType not generating a table name
Browse files Browse the repository at this point in the history
  • Loading branch information
markbates committed Aug 17, 2016
1 parent c002160 commit 90c1350
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions dialect.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,14 @@ func genericExec(store Store, stmt string) error {

func genericSelectOne(store Store, model *Model, query Query) error {
sql, args := query.ToSQL(model)
Log(sql, args...)
err := store.Get(model.Value, sql, args...)
return err
}

func genericSelectMany(store Store, models *Model, query Query) error {
sql, args := query.ToSQL(models)
Log(sql, args...)
err := store.Select(models.Value, sql, args...)
return err
}
3 changes: 3 additions & 0 deletions model.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ func (m *Model) typeName(t reflect.Type) string {
case "string":
return m.Value.(string)
case "slice":
if t.Elem().Kind().String() == "ptr" {
return m.typeName(t.Elem().Elem())
}
return t.Elem().Name()
default:
return t.Name()
Expand Down
4 changes: 4 additions & 0 deletions model_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ func Test_Model_TableName(t *testing.T) {

m = pop.Model{Value: &[]User{}}
r.Equal(m.TableName(), "users")

m = pop.Model{Value: []*User{}}
r.Equal(m.TableName(), "users")

}

func Test_MapTableName(t *testing.T) {
Expand Down
1 change: 0 additions & 1 deletion test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ function test {
echo "Testing $1"
export SODA_DIALECT=$1
echo ./tsoda -v
echo $SODA_DIALECT
! ./tsoda drop -e $SODA_DIALECT -c ./database.yml
! ./tsoda create -e $SODA_DIALECT -c ./database.yml
./tsoda migrate -e $SODA_DIALECT -c ./database.yml -d
Expand Down

0 comments on commit 90c1350

Please sign in to comment.