Should not break on empty database

This commit is contained in:
Deluan 2016-03-02 17:44:33 -05:00
parent 4ee840a394
commit de94fe3ef2

View File

@ -110,11 +110,13 @@ func (r *baseRepository) readEntity(id string) (interface{}, error) {
func (r *baseRepository) toEntity(response [][]byte, entity interface{}) error {
var record = make(map[string]interface{}, len(response))
for i, v := range response {
var value interface{}
if err := json.Unmarshal(v, &value); err != nil {
return err
if len(v) > 0 {
var value interface{}
if err := json.Unmarshal(v, &value); err != nil {
return err
}
record[string(r.fieldNames[i])] = value
}
record[string(r.fieldNames[i])] = value
}
return utils.ToStruct(record, entity)