Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
modls
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Shane O'Neill
modls
Commits
9d7184ed
Commit
9d7184ed
authored
Feb 19, 2014
by
Jason Moiron
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #11 from silasdavis/TableNameMapper
Added TableNameMapper to modl
parents
992aacda
aefb3178
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
2 deletions
+6
-2
dbmap.go
dbmap.go
+6
-2
No files found.
dbmap.go
View file @
9d7184ed
...
...
@@ -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
=
Table
NameMapper
(
t
.
Name
())
}
// check if we have a table for this type already
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment