Commit aefb3178 authored by Silas Davis's avatar Silas Davis

added TableNameMapper to modl

parent 992aacda
......@@ -16,10 +16,14 @@ import (
"fmt"
"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
// 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
// mapped tables.
......@@ -83,7 +87,7 @@ func (m *DbMap) AddTable(i interface{}, name ...string) *TableMap {
t := reflect.TypeOf(i)
// Use sqlx's NameMapper function if no name is supplied
if len(Name) == 0 {
Name = sqlx.NameMapper(t.Name())
Name = TableNameMapper(t.Name())
}
// check if we have a table for this type already
......
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