From dbc95b5c283dc2cbb36d0de8a99f889b222f4ef0 Mon Sep 17 00:00:00 2001 From: Melvin Date: Thu, 15 Dec 2016 16:59:03 -0800 Subject: [PATCH] Handle some special cases --- mapper.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/mapper.go b/mapper.go index 96f2ec5..e1c464b 100644 --- a/mapper.go +++ b/mapper.go @@ -82,6 +82,16 @@ func (m *mapper) unpackStruct(keys []string, values []interface{}, out reflect.V convKey = m.conv.ColumnToFieldName(k) } field := out.FieldByName(convKey) + + // If the field is not found it can mean that we don't want it or that + // we have special case like UserID, UUID, userUUID + // So fix the name and try again + if !field.IsValid() { + convKey = strings.Replace(convKey, "Uuid", "UUID", -1) + convKey = strings.Replace(convKey, "Id", "ID", -1) + field = out.FieldByName(convKey) + } + if field.IsValid() { m.unpackValue(nil, values[i:i+1], field) }