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

Function IsPreDefTypeChanged

schema/schema.go:936–958  ·  view source on GitHub ↗

IsPreDefTypeChanged returns true if the initial update for the pre-defined type is different than the passed update. If the passed update is not a pre-defined type than it just returns false.

(update *pb.TypeUpdate)

Source from the content-addressed store, hash-verified

934// type is different than the passed update.
935// If the passed update is not a pre-defined type than it just returns false.
936func IsPreDefTypeChanged(update *pb.TypeUpdate) bool {
937 // Return false for non-pre-defined types.
938 if !x.IsPreDefinedType(update.TypeName) {
939 return false
940 }
941
942 initialTypes := CompleteInitialTypes(x.ParseNamespace(update.TypeName))
943 for _, original := range initialTypes {
944 if original.TypeName != update.TypeName {
945 continue
946 }
947 if len(original.Fields) != len(update.Fields) {
948 return true
949 }
950 for i, field := range original.Fields {
951 if field.Predicate != update.Fields[i].Predicate {
952 return true
953 }
954 }
955 }
956
957 return false
958}
959
960func reset() {
961 pstate = new(state)

Callers 1

Calls 3

IsPreDefinedTypeFunction · 0.92
ParseNamespaceFunction · 0.92
CompleteInitialTypesFunction · 0.85

Tested by

no test coverage detected