[go: nahoru, domu]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed table detection for []*T #16

Merged
merged 1 commit into from
Apr 29, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fixed table detection for []*T
  • Loading branch information
ulfurinn committed Apr 29, 2014
commit ca3f5caaa02788e0a72f5cb1e6c509602075fc5d
6 changes: 5 additions & 1 deletion dbmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@ import (
"log"
"reflect"
"strings"

"github.com/jmoiron/sqlx"
)

// TableNameMapper is the function used by AddTable to map struct names to database table names, in analogy
// to sqlx.NameMapper which does the same for struct field name to database column names.
var TableNameMapper = strings.ToLower
var TableNameMapper = strings.ToLower

// DbMap is the root modl mapping object. Create one of these for each
// database schema you wish to map. Each DbMap contains a list of
Expand Down Expand Up @@ -375,6 +376,9 @@ start:
default:
t = v.Type()
}
if t.Kind() == reflect.Ptr {
t = t.Elem()
}
return m.TableForType(t)
}

Expand Down
1 change: 1 addition & 0 deletions modl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,7 @@ func TestHooks(t *testing.T) {
t.Errorf("p1.PostGet() didn't run: %v", p1)
}

p1.LName = "smith"
_update(dbmap, p1)
if p1.FName != "preupdate" {
t.Errorf("p1.PreUpdate() didn't run: %v", p1)
Expand Down