convert from task.Val to types.Value, based on schema appropriate type is already set in api.Value
(tv *pb.TaskValue, attr string)
| 423 | // convert from task.Val to types.Value, based on schema appropriate type |
| 424 | // is already set in api.Value |
| 425 | func convertWithBestEffort(tv *pb.TaskValue, attr string) (types.Val, error) { |
| 426 | // value would be in binary format with appropriate type |
| 427 | tid := types.TypeID(tv.ValType) |
| 428 | if !tid.IsScalar() { |
| 429 | return types.Val{}, errors.Errorf("Leaf predicate:'%v' must be a scalar.", attr) |
| 430 | } |
| 431 | |
| 432 | // creates appropriate type from binary format |
| 433 | sv, err := types.Convert(types.Val{Tid: types.BinaryID, Value: tv.Val}, tid) |
| 434 | if err != nil { |
| 435 | // This can happen when a mutation ingests corrupt data into the database. |
| 436 | return types.Val{}, errors.Wrapf(err, "error interpreting appropriate type for %v", attr) |
| 437 | } |
| 438 | return sv, nil |
| 439 | } |
| 440 | |
| 441 | func mathCopy(dst *mathTree, src *dql.MathTree) error { |
| 442 | // Either we'll have an operation specified, or the function specified. |
no test coverage detected