prevent panic when struct with unexport field #1839

Merged
lunny merged 4 commits from :fix_panic_with_unexport_fields into master 2020-12-02 14:07:45 +00:00
Showing only changes of commit 55e7f68a77 - Show all commits

View File

@ -44,12 +44,6 @@ func TestParseTableName(t *testing.T) {
}
func TestUnexportField(t *testing.T) {
type VanilaStruct struct {
private int
Public int
}
parser := NewParser(
"xorm",
dialects.QueryDialect("mysql"),
@ -58,6 +52,10 @@ func TestUnexportField(t *testing.T) {
caches.NewManager(),
)
type VanilaStruct struct {
private int
Public int
}
table, err := parser.Parse(reflect.ValueOf(new(VanilaStruct)))
assert.NoError(t, err)
assert.EqualValues(t, "vanila_struct", table.Name)
@ -72,7 +70,6 @@ func TestUnexportField(t *testing.T) {
private int `xorm:"private"`
Public int `xorm:"-"`
}
table, err = parser.Parse(reflect.ValueOf(new(TaggedStruct)))
assert.NoError(t, err)
assert.EqualValues(t, "tagged_struct", table.Name)