Skip to content

Parser for type declaration. #2950

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

Merged
merged 11 commits into from
Feb 5, 2019
4 changes: 2 additions & 2 deletions dgraph/cmd/bulk/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,9 @@ func readSchema(filename string) []*pb.SchemaUpdate {
buf, err := ioutil.ReadAll(r)
x.Check(err)

initialSchema, err := schema.Parse(string(buf))
result, err := schema.Parse(string(buf))
x.Check(err)
return initialSchema
return result.Schemas
}

func findDataFiles(dir string, ext string) []string {
Expand Down
4 changes: 2 additions & 2 deletions edgraph/access_ee.go
Original file line number Diff line number Diff line change
Expand Up @@ -462,11 +462,11 @@ func authorizeAlter(ctx context.Context, op *api.Operation) error {
return nil
}

updates, err := schema.Parse(op.Schema)
result, err := schema.Parse(op.Schema)
if err != nil {
return err
}
for _, update := range updates {
for _, update := range result.Schemas {
if err := authorizePredicate(groupIds, update.Predicate, acl.Modify); err != nil {
return status.Error(codes.PermissionDenied,
fmt.Sprintf("unauthorized to alter the predicate: %v", err))
Expand Down
6 changes: 3 additions & 3 deletions edgraph/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,13 +327,13 @@ func (s *Server) Alter(ctx context.Context, op *api.Operation) (*api.Payload, er
return empty, err
}

updates, err := schema.Parse(op.Schema)
result, err := schema.Parse(op.Schema)
if err != nil {
return empty, err
}
glog.Infof("Got schema: %+v\n", updates)
glog.Infof("Got schema: %+v\n", result.Schemas)
// TODO: Maybe add some checks about the schema.
m.Schema = updates
m.Schema = result.Schemas
_, err = query.ApplyMutations(ctx, m)
return empty, err
}
Expand Down
Binary file added git-branch-cleanup
Binary file not shown.
15 changes: 14 additions & 1 deletion protos/pb.proto
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ message Posting {
UID = 7;
PASSWORD = 8;
STRING = 9;

OBJECT = 10;
}
ValType val_type = 3;
enum PostingType {
Expand Down Expand Up @@ -338,11 +338,24 @@ message SchemaUpdate {
bool upsert = 8;
bool lang = 9;

// Fields required for type system.
bool non_nullable = 10;
bool non_nullable_list = 11;

// If value_type is OBJECT, then this represents an object type with a
// custom name. This field stores said name.
string object_type_name = 12;

// Deleted field:
reserved 7;
reserved "explicit";
}

message TypeUpdate {
string type_name = 1;
repeated SchemaUpdate fields = 2;
}

// Bulk loader proto.
message MapEntry {
bytes key = 1;
Expand Down
Loading