prevent panic when struct with unexport field #1839
|
@ -44,12 +44,6 @@ func TestParseTableName(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestUnexportField(t *testing.T) {
|
func TestUnexportField(t *testing.T) {
|
||||||
|
|
||||||
type VanilaStruct struct {
|
|
||||||
private int
|
|
||||||
Public int
|
|
||||||
}
|
|
||||||
|
|
||||||
parser := NewParser(
|
parser := NewParser(
|
||||||
"xorm",
|
"xorm",
|
||||||
dialects.QueryDialect("mysql"),
|
dialects.QueryDialect("mysql"),
|
||||||
|
@ -58,6 +52,10 @@ func TestUnexportField(t *testing.T) {
|
||||||
caches.NewManager(),
|
caches.NewManager(),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type VanilaStruct struct {
|
||||||
|
private int
|
||||||
|
Public int
|
||||||
|
}
|
||||||
table, err := parser.Parse(reflect.ValueOf(new(VanilaStruct)))
|
table, err := parser.Parse(reflect.ValueOf(new(VanilaStruct)))
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.EqualValues(t, "vanila_struct", table.Name)
|
assert.EqualValues(t, "vanila_struct", table.Name)
|
||||||
|
@ -72,7 +70,6 @@ func TestUnexportField(t *testing.T) {
|
||||||
private int `xorm:"private"`
|
private int `xorm:"private"`
|
||||||
Public int `xorm:"-"`
|
Public int `xorm:"-"`
|
||||||
}
|
}
|
||||||
|
|
||||||
table, err = parser.Parse(reflect.ValueOf(new(TaggedStruct)))
|
table, err = parser.Parse(reflect.ValueOf(new(TaggedStruct)))
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.EqualValues(t, "tagged_struct", table.Name)
|
assert.EqualValues(t, "tagged_struct", table.Name)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user