diff --git a/mapping_document.go b/mapping_document.go index a1c96dc0..fc74a67f 100644 --- a/mapping_document.go +++ b/mapping_document.go @@ -254,7 +254,7 @@ func (dm *DocumentMapping) walkDocument(data interface{}, path []string, indexes case reflect.Ptr: ptrElem := val.Elem() if ptrElem.IsValid() && ptrElem.CanInterface() { - dm.walkDocument(ptrElem.Interface(), path, indexes, context) + dm.processProperty(ptrElem.Interface(), path, indexes, context) } } } diff --git a/mapping_test.go b/mapping_test.go index 13c09259..417674ec 100644 --- a/mapping_test.go +++ b/mapping_test.go @@ -150,3 +150,36 @@ func TestMappingStructWithJSONTagsOneDisabled(t *testing.T) { 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) + } +}