From b72aefdc290e1fda41f434f71129ef82ef8d8084 Mon Sep 17 00:00:00 2001 From: Pawan Rawal <pawan0201@gmail.com> Date: Thu, 28 Apr 2016 16:06:46 +0530 Subject: [PATCH] modifying Value method --- client/client.go | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/client/client.go b/client/client.go index bcb39dc5..1f71857a 100644 --- a/client/client.go +++ b/client/client.go @@ -91,19 +91,18 @@ func (e *Entity) HasValue(property string) bool { // This method returns the value corresponding to a property if one exists. func (e *Entity) Value(property string) []byte { for _, predChild := range e.gr.Children { - if len(predChild.Children) > 0 || predChild.Attribute != property { - continue - } - idx := indexOf(e.uid, predChild.Query.Uids) - if idx == -1 { - glog.WithFields(logrus.Fields{ - "uid": e.uid, - "attribute": e.Attribute, - "childAttribute": predChild.Attribute, - }).Fatal("Attribute with uid not found in child Query uids") - return []byte{} + if predChild.Attribute == property { + idx := indexOf(e.uid, predChild.Query.Uids) + if idx == -1 { + glog.WithFields(logrus.Fields{ + "uid": e.uid, + "attribute": e.Attribute, + "childAttribute": predChild.Attribute, + }).Fatal("Attribute with uid not found in child Query uids") + return []byte{} + } + return predChild.Result.Values[idx] } - return predChild.Result.Values[idx] } return []byte{} } -- GitLab