(attr string, typ types.TypeID, hint pb.Metadata_HintType, ts uint64)
| 299 | } |
| 300 | |
| 301 | func createSchema(attr string, typ types.TypeID, hint pb.Metadata_HintType, ts uint64) error { |
| 302 | ctx := schema.GetWriteContext(context.Background()) |
| 303 | |
| 304 | // Don't overwrite schema blindly, acl's might have been set even though |
| 305 | // type is not present |
| 306 | s, ok := schema.State().Get(ctx, attr) |
| 307 | if ok { |
| 308 | s.ValueType = typ.Enum() |
| 309 | } else { |
| 310 | s = pb.SchemaUpdate{ValueType: typ.Enum(), Predicate: attr} |
| 311 | // For type UidID, set List to true. This is done because previously |
| 312 | // all predicates of type UidID were implicitly considered lists. |
| 313 | if typ == types.UidID { |
| 314 | s.List = true |
| 315 | } |
| 316 | |
| 317 | switch hint { |
| 318 | case pb.Metadata_SINGLE: |
| 319 | s.List = false |
| 320 | case pb.Metadata_LIST: |
| 321 | s.List = true |
| 322 | default: |
| 323 | } |
| 324 | } |
| 325 | if err := checkSchema(&s); err != nil { |
| 326 | return err |
| 327 | } |
| 328 | return updateSchema(&s, ts) |
| 329 | } |
| 330 | |
| 331 | func runTypeMutation(ctx context.Context, update *pb.TypeUpdate, ts uint64) error { |
| 332 | current := proto.Clone(update).(*pb.TypeUpdate) |
no test coverage detected