Skip to content

Commit 6bb9aea

Browse files
martinmrdna2github
authored andcommitted
Rename type predicate to dgraph.type (hypermodeinc#3204)
1 parent 4a32006 commit 6bb9aea

File tree

9 files changed

+23
-23
lines changed

9 files changed

+23
-23
lines changed

Diff for: dgraph/cmd/alpha/run_test.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ func TestDeletePredicate(t *testing.T) {
276276
`{"predicate":"age","type":"default"},`+
277277
`{"predicate":"name","type":"string","index":true, "tokenizer":["term"]},`+
278278
x.AclPredicates+","+
279-
`{"predicate":"type","type":"string","index":true, "tokenizer":["exact"]}`+
279+
`{"predicate":"dgraph.type","type":"string","index":true, "tokenizer":["exact"]}`+
280280
`]}}`, output)
281281

282282
output, err = runQuery(q1)
@@ -1350,7 +1350,7 @@ func TestListTypeSchemaChange(t *testing.T) {
13501350
x.AclPredicates+","+
13511351
`{"predicate":"_predicate_","type":"string","list":true},`+
13521352
`{"predicate":"occupations","type":"string"},`+
1353-
`{"predicate":"type", "type":"string", "index":true, "tokenizer": ["exact"]}]}}`, res)
1353+
`{"predicate":"dgraph.type", "type":"string", "index":true, "tokenizer": ["exact"]}]}}`, res)
13541354
}
13551355

13561356
func TestDeleteAllSP2(t *testing.T) {
@@ -1507,7 +1507,7 @@ func TestDropAll(t *testing.T) {
15071507
z.CompareJSON(t,
15081508
`{"data":{"schema":[{"predicate":"_predicate_","type":"string","list":true},`+
15091509
x.AclPredicates+","+
1510-
`{"predicate":"type", "type":"string", "index":true, "tokenizer":["exact"]}]}}`, output)
1510+
`{"predicate":"dgraph.type", "type":"string", "index":true, "tokenizer":["exact"]}]}}`, output)
15111511

15121512
// Reinstate schema so that we can re-run the original query.
15131513
err = alterSchemaWithRetry(s)
@@ -1613,11 +1613,11 @@ func TestTypeMutationAndQuery(t *testing.T) {
16131613
"set": [
16141614
{
16151615
"name": "Alice",
1616-
"type": "Employee"
1616+
"dgraph.type": "Employee"
16171617
},
16181618
{
16191619
"name": "Bob",
1620-
"type": "Employer"
1620+
"dgraph.type": "Employer"
16211621
}
16221622
]
16231623
}

Diff for: ee/acl/acl.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ func groupAdd(conf *viper.Viper, groupId string) error {
159159
},
160160
{
161161
Subject: "_:newgroup",
162-
Predicate: "type",
162+
Predicate: "dgraph.type",
163163
ObjectValue: &api.Value{Val: &api.Value_StrVal{StrVal: "Group"}},
164164
},
165165
}

Diff for: ee/acl/utils.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ func CreateUserNQuads(userId string, password string) []*api.NQuad {
247247
},
248248
{
249249
Subject: "_:newuser",
250-
Predicate: "type",
250+
Predicate: "dgraph.type",
251251
ObjectValue: &api.Value{Val: &api.Value_StrVal{StrVal: "User"}},
252252
},
253253
}

Diff for: query/common_test.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -474,11 +474,11 @@ func populateCluster() {
474474
<23> <shadow_deep> "4" .
475475
<24> <shadow_deep> "14" .
476476
477-
<2> <type> "Person" .
478-
<3> <type> "Person" .
479-
<4> <type> "Person" .
480-
<5> <type> "Animal" .
481-
<6> <type> "Animal" .
477+
<2> <dgraph.type> "Person" .
478+
<3> <dgraph.type> "Person" .
479+
<4> <dgraph.type> "Person" .
480+
<5> <dgraph.type> "Animal" .
481+
<6> <dgraph.type> "Animal" .
482482
483483
<2> <pet> <5> .
484484
<3> <pet> <6> .

Diff for: query/query.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -229,9 +229,9 @@ func (sg *SubGraph) createSrcFunction(gf *gql.Function) {
229229
IsValueVar: gf.IsValueVar,
230230
}
231231

232-
// type function is just an alias for eq(type, "type").
232+
// type function is just an alias for eq(type, "dgraph.type").
233233
if gf.Name == "type" {
234-
sg.Attr = "type"
234+
sg.Attr = "dgraph.type"
235235
sg.SrcFunc.Name = "eq"
236236
sg.SrcFunc.IsCount = false
237237
sg.SrcFunc.IsValueVar = false

Diff for: schema/schema.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ func InitialSchema() []*pb.SchemaUpdate {
421421
}
422422

423423
initialSchema = append(initialSchema, &pb.SchemaUpdate{
424-
Predicate: "type",
424+
Predicate: "dgraph.type",
425425
ValueType: pb.Posting_STRING,
426426
Directive: pb.SchemaUpdate_INDEX,
427427
Tokenizer: []string{"exact"},

Diff for: systest/mutations_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -685,7 +685,7 @@ func SchemaAfterDeleteNode(t *testing.T, c *dgo.Dgraph) {
685685
`{"predicate":"friend","type":"uid","list":true},`+
686686
`{"predicate":"married","type":"bool"},`+
687687
`{"predicate":"name","type":"default"},`+
688-
`{"predicate":"type","type":"string","index":true, "tokenizer":["exact"]}]`),
688+
`{"predicate":"dgraph.type","type":"string","index":true, "tokenizer":["exact"]}]`),
689689
string(resp.Json))
690690

691691
require.NoError(t, c.Alter(ctx, &api.Operation{DropAttr: "married"}))
@@ -706,7 +706,7 @@ func SchemaAfterDeleteNode(t *testing.T, c *dgo.Dgraph) {
706706
`{"predicate":"_predicate_","type":"string","list":true},`+
707707
`{"predicate":"friend","type":"uid","list":true},`+
708708
`{"predicate":"name","type":"default"},`+
709-
`{"predicate":"type","type":"string","index":true, "tokenizer":["exact"]}]`),
709+
`{"predicate":"dgraph.type","type":"string","index":true, "tokenizer":["exact"]}]`),
710710
string(resp.Json))
711711
}
712712

@@ -1719,8 +1719,8 @@ func RestoreReservedPreds(t *testing.T, c *dgo.Dgraph) {
17191719
require.NoError(t, err)
17201720

17211721
// Verify that the reserved predicates were restored to the schema.
1722-
query := `schema(preds: type) {predicate}`
1722+
query := `schema(preds: dgraph.type) {predicate}`
17231723
resp, err := c.NewReadOnlyTxn().Query(ctx, query)
17241724
require.NoError(t, err)
1725-
CompareJSON(t, `{"schema": [{"predicate":"type"}]}`, string(resp.Json))
1725+
CompareJSON(t, `{"schema": [{"predicate":"dgraph.type"}]}`, string(resp.Json))
17261726
}

Diff for: systest/queries_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ func SchemaQueryTest(t *testing.T, c *dgo.Dgraph) {
337337
"list": true
338338
},
339339
{
340-
"predicate": "type",
340+
"predicate": "dgraph.type",
341341
"type": "string",
342342
"index": true,
343343
"tokenizer": [
@@ -405,7 +405,7 @@ func SchemaQueryTestPredicate1(t *testing.T, c *dgo.Dgraph) {
405405
"predicate": "friends"
406406
},
407407
{
408-
"predicate": "type"
408+
"predicate": "dgraph.type"
409409
},
410410
{
411411
"predicate": "name"
@@ -533,7 +533,7 @@ func SchemaQueryTestHTTP(t *testing.T, c *dgo.Dgraph) {
533533
},
534534
{
535535
"index": true,
536-
"predicate": "type",
536+
"predicate": "dgraph.type",
537537
"type": "string",
538538
"tokenizer": ["exact"]
539539
},

Diff for: x/keys.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ func Parse(key []byte) *ParsedKey {
330330
func IsReservedPredicate(pred string) bool {
331331
var m = map[string]struct{}{
332332
PredicateListAttr: {},
333-
"type": {},
333+
"dgraph.type": {},
334334
}
335335
_, ok := m[strings.ToLower(pred)]
336336
return ok || IsAclPredicate(pred)

0 commit comments

Comments
 (0)