convertValue converts the data to the schema.State() type of predicate.
(attr, data string)
| 169 | |
| 170 | // convertValue converts the data to the schema.State() type of predicate. |
| 171 | func convertValue(attr, data string) (types.Val, error) { |
| 172 | // Parse given value and get token. There should be only one token. |
| 173 | t, err := schema.State().TypeOf(attr) |
| 174 | if err != nil { |
| 175 | return types.Val{}, err |
| 176 | } |
| 177 | if !t.IsScalar() { |
| 178 | return types.Val{}, errors.Errorf("Attribute %s is not valid scalar type", |
| 179 | x.ParseAttr(attr)) |
| 180 | } |
| 181 | src := types.Val{Tid: types.StringID, Value: []byte(data)} |
| 182 | dst, err := types.Convert(src, t) |
| 183 | return dst, err |
| 184 | } |
| 185 | |
| 186 | // Returns nil byte on error |
| 187 | func convertToType(v types.Val, typ types.TypeID) (*pb.TaskValue, error) { |