Commit ca3f5caa authored by Valeri Sokolov's avatar Valeri Sokolov

fixed table detection for []*T

parent 9d253d1d
......@@ -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
......@@ -375,6 +376,9 @@ start:
default:
t = v.Type()
}
if t.Kind() == reflect.Ptr {
t = t.Elem()
}
return m.TableForType(t)
}
......
......@@ -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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment