From fda26ef5f9d131bc1901f73fe949eeed0b43b34b Mon Sep 17 00:00:00 2001 From: Martin Martinez Rivera Date: Mon, 22 Jul 2019 15:10:40 -0700 Subject: [PATCH 1/2] Fix bug when exporting a predicate name to the schema. This change is fixing #3699 for the 1.0 branch. The logic in this branch was slightly different. In this case, the brackets are only added if there's a colon in the predicate name. This logic is also buggy as it doesn't handle predicate names consisting of only numbers. The fix is to add the brackets for every predicate name for consistency and simplicity. --- worker/export.go | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/worker/export.go b/worker/export.go index a1c338a770e..d204a9b01c5 100644 --- a/worker/export.go +++ b/worker/export.go @@ -156,13 +156,9 @@ func toRDF(pl *posting.List, prefix string, readTs uint64) (*bpb.KVList, error) func toSchema(attr string, update pb.SchemaUpdate) (*bpb.KVList, error) { // bytes.Buffer never returns error for any of the writes. So, we don't need to check them. var buf bytes.Buffer - if strings.ContainsRune(attr, ':') { - buf.WriteRune('<') - buf.WriteString(attr) - buf.WriteRune('>') - } else { - buf.WriteString(attr) - } + buf.WriteRune('<') + buf.WriteString(attr) + buf.WriteRune('>') buf.WriteByte(':') if update.List { buf.WriteRune('[') From e4d23f29f4b2926c3deb52a8ad01db70a2640351 Mon Sep 17 00:00:00 2001 From: Martin Martinez Rivera Date: Mon, 22 Jul 2019 17:49:30 -0700 Subject: [PATCH 2/2] Fix tests. --- worker/export_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/worker/export_test.go b/worker/export_test.go index 2ed37b1f1cc..0b364ea6879 100644 --- a/worker/export_test.go +++ b/worker/export_test.go @@ -262,7 +262,7 @@ func TestToSchema(t *testing.T) { Lang: true, }, }, - expected: "Alice:string @reverse @count @lang @upsert . \n", + expected: ":string @reverse @count @lang @upsert . \n", }, { skv: &skv{