Skip to content

Commit

Permalink
Rename type predicate to dgraph.type (dgraph-io#3204)
Browse files Browse the repository at this point in the history
  • Loading branch information
martinmr authored and dna2github committed Jul 19, 2019
1 parent 4a32006 commit 6bb9aea
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 23 deletions.
10 changes: 5 additions & 5 deletions dgraph/cmd/alpha/run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ func TestDeletePredicate(t *testing.T) {
`{"predicate":"age","type":"default"},`+
`{"predicate":"name","type":"string","index":true, "tokenizer":["term"]},`+
x.AclPredicates+","+
`{"predicate":"type","type":"string","index":true, "tokenizer":["exact"]}`+
`{"predicate":"dgraph.type","type":"string","index":true, "tokenizer":["exact"]}`+
`]}}`, output)

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

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

// Reinstate schema so that we can re-run the original query.
err = alterSchemaWithRetry(s)
Expand Down Expand Up @@ -1613,11 +1613,11 @@ func TestTypeMutationAndQuery(t *testing.T) {
"set": [
{
"name": "Alice",
"type": "Employee"
"dgraph.type": "Employee"
},
{
"name": "Bob",
"type": "Employer"
"dgraph.type": "Employer"
}
]
}
Expand Down
2 changes: 1 addition & 1 deletion ee/acl/acl.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ func groupAdd(conf *viper.Viper, groupId string) error {
},
{
Subject: "_:newgroup",
Predicate: "type",
Predicate: "dgraph.type",
ObjectValue: &api.Value{Val: &api.Value_StrVal{StrVal: "Group"}},
},
}
Expand Down
2 changes: 1 addition & 1 deletion ee/acl/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ func CreateUserNQuads(userId string, password string) []*api.NQuad {
},
{
Subject: "_:newuser",
Predicate: "type",
Predicate: "dgraph.type",
ObjectValue: &api.Value{Val: &api.Value_StrVal{StrVal: "User"}},
},
}
Expand Down
10 changes: 5 additions & 5 deletions query/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -474,11 +474,11 @@ func populateCluster() {
<23> <shadow_deep> "4" .
<24> <shadow_deep> "14" .
<2> <type> "Person" .
<3> <type> "Person" .
<4> <type> "Person" .
<5> <type> "Animal" .
<6> <type> "Animal" .
<2> <dgraph.type> "Person" .
<3> <dgraph.type> "Person" .
<4> <dgraph.type> "Person" .
<5> <dgraph.type> "Animal" .
<6> <dgraph.type> "Animal" .
<2> <pet> <5> .
<3> <pet> <6> .
Expand Down
4 changes: 2 additions & 2 deletions query/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,9 @@ func (sg *SubGraph) createSrcFunction(gf *gql.Function) {
IsValueVar: gf.IsValueVar,
}

// type function is just an alias for eq(type, "type").
// type function is just an alias for eq(type, "dgraph.type").
if gf.Name == "type" {
sg.Attr = "type"
sg.Attr = "dgraph.type"
sg.SrcFunc.Name = "eq"
sg.SrcFunc.IsCount = false
sg.SrcFunc.IsValueVar = false
Expand Down
2 changes: 1 addition & 1 deletion schema/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ func InitialSchema() []*pb.SchemaUpdate {
}

initialSchema = append(initialSchema, &pb.SchemaUpdate{
Predicate: "type",
Predicate: "dgraph.type",
ValueType: pb.Posting_STRING,
Directive: pb.SchemaUpdate_INDEX,
Tokenizer: []string{"exact"},
Expand Down
8 changes: 4 additions & 4 deletions systest/mutations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,7 @@ func SchemaAfterDeleteNode(t *testing.T, c *dgo.Dgraph) {
`{"predicate":"friend","type":"uid","list":true},`+
`{"predicate":"married","type":"bool"},`+
`{"predicate":"name","type":"default"},`+
`{"predicate":"type","type":"string","index":true, "tokenizer":["exact"]}]`),
`{"predicate":"dgraph.type","type":"string","index":true, "tokenizer":["exact"]}]`),
string(resp.Json))

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

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

// Verify that the reserved predicates were restored to the schema.
query := `schema(preds: type) {predicate}`
query := `schema(preds: dgraph.type) {predicate}`
resp, err := c.NewReadOnlyTxn().Query(ctx, query)
require.NoError(t, err)
CompareJSON(t, `{"schema": [{"predicate":"type"}]}`, string(resp.Json))
CompareJSON(t, `{"schema": [{"predicate":"dgraph.type"}]}`, string(resp.Json))
}
6 changes: 3 additions & 3 deletions systest/queries_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ func SchemaQueryTest(t *testing.T, c *dgo.Dgraph) {
"list": true
},
{
"predicate": "type",
"predicate": "dgraph.type",
"type": "string",
"index": true,
"tokenizer": [
Expand Down Expand Up @@ -405,7 +405,7 @@ func SchemaQueryTestPredicate1(t *testing.T, c *dgo.Dgraph) {
"predicate": "friends"
},
{
"predicate": "type"
"predicate": "dgraph.type"
},
{
"predicate": "name"
Expand Down Expand Up @@ -533,7 +533,7 @@ func SchemaQueryTestHTTP(t *testing.T, c *dgo.Dgraph) {
},
{
"index": true,
"predicate": "type",
"predicate": "dgraph.type",
"type": "string",
"tokenizer": ["exact"]
},
Expand Down
2 changes: 1 addition & 1 deletion x/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ func Parse(key []byte) *ParsedKey {
func IsReservedPredicate(pred string) bool {
var m = map[string]struct{}{
PredicateListAttr: {},
"type": {},
"dgraph.type": {},
}
_, ok := m[strings.ToLower(pred)]
return ok || IsAclPredicate(pred)
Expand Down

0 comments on commit 6bb9aea

Please sign in to comment.