-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #69: support customizable table name mapping
- Loading branch information
Showing
7 changed files
with
51 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -74,7 +74,7 @@ func Test_structValue_columns(t *testing.T) { | |
Status: 2, | ||
Email: "[email protected]", | ||
} | ||
sv := newStructValue(&customer, DefaultFieldMapFunc) | ||
sv := newStructValue(&customer, DefaultFieldMapFunc, GetTableName) | ||
cols := sv.columns(nil, nil) | ||
assert.Equal(t, map[string]interface{}{"id": 1, "name": "abc", "status": 2, "email": "[email protected]", "address": sql.NullString{}}, cols) | ||
|
||
|
@@ -87,7 +87,7 @@ func Test_structValue_columns(t *testing.T) { | |
cols = sv.columns(nil, []string{"ID", "Address"}) | ||
assert.Equal(t, map[string]interface{}{"name": "abc", "status": 2, "email": "[email protected]"}, cols) | ||
|
||
sv = newStructValue(&customer, nil) | ||
sv = newStructValue(&customer, nil, GetTableName) | ||
cols = sv.columns([]string{"ID", "Name"}, []string{"ID"}) | ||
assert.Equal(t, map[string]interface{}{"Name": "abc"}, cols) | ||
} | ||
|
@@ -103,22 +103,22 @@ func TestIssue37(t *testing.T) { | |
Customer | ||
Status string | ||
}{customer, "20"} | ||
sv := newStructValue(&ev, nil) | ||
sv := newStructValue(&ev, nil, GetTableName) | ||
cols := sv.columns([]string{"ID", "Status"}, nil) | ||
assert.Equal(t, map[string]interface{}{"ID": 1, "Status": "20"}, cols) | ||
|
||
ev2 := struct { | ||
Status string | ||
Customer | ||
}{"20", customer} | ||
sv = newStructValue(&ev2, nil) | ||
sv = newStructValue(&ev2, nil, GetTableName) | ||
cols = sv.columns([]string{"ID", "Status"}, nil) | ||
assert.Equal(t, map[string]interface{}{"ID": 1, "Status": "20"}, cols) | ||
} | ||
|
||
type MyCustomer struct{} | ||
|
||
func Test_getTableName(t *testing.T) { | ||
func TestGetTableName(t *testing.T) { | ||
var c1 Customer | ||
assert.Equal(t, "customer", GetTableName(c1)) | ||
|
||
|