Merge branch 'StreamBoat-fix_ptr_handling'
This commit is contained in:
commit
3e72949563
|
@ -254,7 +254,7 @@ func (dm *DocumentMapping) walkDocument(data interface{}, path []string, indexes
|
||||||
case reflect.Ptr:
|
case reflect.Ptr:
|
||||||
ptrElem := val.Elem()
|
ptrElem := val.Elem()
|
||||||
if ptrElem.IsValid() && ptrElem.CanInterface() {
|
if ptrElem.IsValid() && ptrElem.CanInterface() {
|
||||||
dm.walkDocument(ptrElem.Interface(), path, indexes, context)
|
dm.processProperty(ptrElem.Interface(), path, indexes, context)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -150,3 +150,36 @@ func TestMappingStructWithJSONTagsOneDisabled(t *testing.T) {
|
||||||
t.Errorf("expected to find 2 find, found %d", count)
|
t.Errorf("expected to find 2 find, found %d", count)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestMappingStructWithPointerToString(t *testing.T) {
|
||||||
|
|
||||||
|
mapping := buildMapping()
|
||||||
|
|
||||||
|
name := "marty"
|
||||||
|
|
||||||
|
x := struct {
|
||||||
|
Name *string
|
||||||
|
}{
|
||||||
|
Name: &name,
|
||||||
|
}
|
||||||
|
|
||||||
|
doc := document.NewDocument("1")
|
||||||
|
err := mapping.mapDocument(doc, x)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
found := false
|
||||||
|
count := 0
|
||||||
|
for _, f := range doc.Fields {
|
||||||
|
if f.Name() == "Name" {
|
||||||
|
found = true
|
||||||
|
}
|
||||||
|
count++
|
||||||
|
}
|
||||||
|
if !found {
|
||||||
|
t.Errorf("expected to find field named 'Name'")
|
||||||
|
}
|
||||||
|
if count != 1 {
|
||||||
|
t.Errorf("expected to find 1 find, found %d", count)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user