Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set default type predicates as lists. #3792

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion dgraph/cmd/bulk/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,11 @@ func (s *schemaStore) validateType(de *pb.DirectedEdge, objectIsUID bool) {
sch, ok = s.schemaMap[de.Attr]
if !ok {
sch = &pb.SchemaUpdate{ValueType: de.ValueType}
if objectIsUID {
// For type uid or default, set List to true. This is done for UIDs because previously
// all predicates of type uid were implicitly considered lists. It's done for the
// default type to prevent data loss when users insert data before setting the schema to
// their desired type.
if objectIsUID || de.ValueType == pb.Posting_DEFAULT {
sch.List = true
}
s.schemaMap[de.Attr] = sch
Expand Down
8 changes: 5 additions & 3 deletions worker/mutation.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,11 @@ func createSchema(attr string, typ types.TypeID) {
s.ValueType = typ.Enum()
} else {
s = pb.SchemaUpdate{ValueType: typ.Enum(), Predicate: attr}
// For type UidID, set List to true. This is done because previously
// all predicates of type UidID were implicitly considered lists.
if typ == types.UidID {
// For type uid or default, set List to true. This is done for UIDs because previously
// all predicates of type uid were implicitly considered lists. It's done for the
// default type to prevent data loss when users insert data before setting the schema to
// their desired type.
if typ == types.UidID || typ == types.DefaultID {
s.List = true
}
}
Expand Down