From 4932af81d4d6bfe5a41d7043f5d718278d0df544 Mon Sep 17 00:00:00 2001 From: Pawan Rawal <pawan0201@gmail.com> Date: Mon, 16 May 2016 08:58:51 +0530 Subject: [PATCH] avoiding interface conversion --- query/query.go | 15 +++------------ query/query_test.go | 6 +++--- 2 files changed, 6 insertions(+), 15 deletions(-) diff --git a/query/query.go b/query/query.go index 30d5f9c3..83a86972 100644 --- a/query/query.go +++ b/query/query.go @@ -327,21 +327,12 @@ func (g *SubGraph) preTraverse(uid uint64, dst *graph.Node) error { return fmt.Errorf("While parsing value") } - var ival interface{} - if err := posting.ParseValue(&ival, tv.ValBytes()); err != nil { - return err - } - - if ival == nil { - ival = "" - } - - v := ival.(string) + v := tv.ValBytes() if pc.Attr == "_xid_" { - dst.Xid = v + dst.Xid = string(v) } else { - p := &graph.Property{Prop: pc.Attr, Val: []byte(v)} + p := &graph.Property{Prop: pc.Attr, Val: v} properties = append(properties, p) } diff --git a/query/query_test.go b/query/query_test.go index 9805a7c3..5450abf1 100644 --- a/query/query_test.go +++ b/query/query_test.go @@ -383,14 +383,14 @@ func TestToPB(t *testing.T) { if gr.Uid != 1 { t.Errorf("Expected uid 1, Got: %v", gr.Uid) } - if gr.Xid != "mich" { + if gr.Xid != `"mich"` { t.Errorf("Expected xid mich, Got: %v", gr.Xid) } if len(gr.Properties) != 3 { t.Errorf("Expected values map to contain 3 properties, Got: %v", len(gr.Properties)) } - if string(getProperty(gr.Properties, "name")) != "Michonne" { + if string(getProperty(gr.Properties, "name")) != `"Michonne"` { t.Errorf("Expected property name to have value Michonne, Got: %v", string(getProperty(gr.Properties, "name"))) } @@ -409,7 +409,7 @@ func TestToPB(t *testing.T) { t.Errorf("Expected values map to contain 1 property, Got: %v", len(child.Properties)) } - if string(getProperty(child.Properties, "name")) != "Rick Grimes" { + if string(getProperty(child.Properties, "name")) != `"Rick Grimes"` { t.Errorf("Expected property name to have value Rick Grimes, Got: %v", string(getProperty(child.Properties, "name"))) } -- GitLab