MCPcopy
hub / github.com/dgraph-io/dgraph / typeSanityCheck

Function typeSanityCheck

worker/mutation.go:863–884  ·  view source on GitHub ↗

typeSanityCheck performs basic sanity checks on the given type update.

(t *pb.TypeUpdate)

Source from the content-addressed store, hash-verified

861
862// typeSanityCheck performs basic sanity checks on the given type update.
863func typeSanityCheck(t *pb.TypeUpdate) error {
864 for _, field := range t.Fields {
865 if x.ParseAttr(field.Predicate) == "" {
866 return errors.Errorf("Field in type definition must have a name")
867 }
868
869 if field.ValueType == pb.Posting_OBJECT && field.ObjectTypeName == "" {
870 return errors.Errorf(
871 "Field with value type OBJECT must specify the name of the object type")
872 }
873
874 if field.Directive != pb.SchemaUpdate_NONE {
875 return errors.Errorf("Field in type definition cannot have a directive")
876 }
877
878 if len(field.Tokenizer) > 0 {
879 return errors.Errorf("Field in type definition cannot have tokenizers")
880 }
881 }
882
883 return nil
884}
885
886// CommitOverNetwork makes a proxy call to Zero to commit or abort a transaction.
887func CommitOverNetwork(ctx context.Context, tc *api.TxnContext) (uint64, error) {

Callers 2

TestTypeSanityCheckFunction · 0.85
verifyTypesFunction · 0.85

Calls 2

ParseAttrFunction · 0.92
ErrorfMethod · 0.45

Tested by 1

TestTypeSanityCheckFunction · 0.68