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