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

Function validateSchema

dgraph/cmd/live/run.go:198–216  ·  view source on GitHub ↗

validate that the schema contains the predicates whose namespace exist.

(sch string, namespaces map[uint64]struct{})

Source from the content-addressed store, hash-verified

196
197// validate that the schema contains the predicates whose namespace exist.
198func validateSchema(sch string, namespaces map[uint64]struct{}) error {
199 result, err := schemapkg.Parse(sch)
200 if err != nil {
201 return err
202 }
203 for _, pred := range result.Preds {
204 ns := x.ParseNamespace(pred.Predicate)
205 if _, ok := namespaces[ns]; !ok {
206 return errors.Errorf("Namespace %#x doesn't exist for pred %s.", ns, pred.Predicate)
207 }
208 }
209 for _, typ := range result.Types {
210 ns := x.ParseNamespace(typ.TypeName)
211 if _, ok := namespaces[ns]; !ok {
212 return errors.Errorf("Namespace %#x doesn't exist for type %s.", ns, typ.TypeName)
213 }
214 }
215 return nil
216}
217
218// processSchemaFile process schema for a given gz file.
219func (l *loader) processSchemaFile(ctx context.Context, file string, key x.Sensitive,

Callers 1

processSchemaFileMethod · 0.85

Calls 3

ParseNamespaceFunction · 0.92
ParseMethod · 0.65
ErrorfMethod · 0.45

Tested by

no test coverage detected