Commit 525c4920 authored by Jason Moiron's avatar Jason Moiron

use sqlx.NameMapper instead of strings.ToLower to map struct names to column names

parent 377aa9ca
......@@ -10,7 +10,6 @@ import (
"github.com/jmoiron/sqlx"
"log"
"reflect"
"strings"
)
// DbMap is the root modl mapping object. Create one of these for each
......@@ -75,7 +74,7 @@ func (m *DbMap) AddTable(i interface{}, name ...string) *TableMap {
t := reflect.TypeOf(i)
if len(Name) == 0 {
Name = strings.ToLower(t.Name())
Name = sqlx.NameMapper(t.Name())
}
// check if we have a table for this type already
......@@ -97,7 +96,7 @@ func (m *DbMap) AddTable(i interface{}, name ...string) *TableMap {
f := t.Field(i)
columnName := f.Tag.Get("db")
if columnName == "" {
columnName = strings.ToLower(f.Name)
columnName = sqlx.NameMapper(f.Name)
}
cm := &ColumnMap{
......
......@@ -3,6 +3,7 @@ package modl
import (
"errors"
"fmt"
"github.com/jmoiron/sqlx"
"reflect"
"strings"
)
......@@ -233,7 +234,7 @@ func (d PostgresDialect) InsertAutoIncr(exec SqlExecutor, insertSql string, para
}
func (d PostgresDialect) QuoteField(f string) string {
return `"` + strings.ToLower(f) + `"`
return `"` + sqlx.NameMapper(f) + `"`
}
func (d PostgresDialect) TruncateClause() string {
......
......@@ -15,7 +15,6 @@ import (
"fmt"
"github.com/jmoiron/sqlx"
"reflect"
"strings"
)
type NoKeysErr struct {
......@@ -100,7 +99,7 @@ func (t *TableMap) ResetSql() {
func (t *TableMap) SetKeys(isAutoIncr bool, fieldNames ...string) *TableMap {
t.keys = make([]*ColumnMap, 0)
for _, name := range fieldNames {
colmap := t.ColMap(strings.ToLower(name))
colmap := t.ColMap(sqlx.NameMapper(name))
colmap.isPK = true
colmap.isAutoIncr = isAutoIncr
t.keys = append(t.keys, colmap)
......
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