Skip to content

Commit

Permalink
Task convertion from bool to int was done using uint32 (#2621)
Browse files Browse the repository at this point in the history
A type conversion check was failing because it expected 8 byte value
to convert to uint64, but the task conversion was returning 4 byte
as uint32. This change fixes that conversion issue.

Closes #2620
  • Loading branch information
srfrog authored Sep 28, 2018
1 parent 6a9a89e commit 8cd1a2a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions gql/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -1754,7 +1754,7 @@ func tryParseFacetList(it *lex.ItemIterator) (res facetRes, parseOk bool, err er
// We've consumed `'@facets' '(' <facetItem> ',' <facetItem>`, so this is definitely
// not a filter. Return an error.
return res, false, x.Errorf(
"Expected ',' or ')' in facet list", item.Val)
"Expected ',' or ')' in facet list: %s", item.Val)
}
}
}
Expand Down Expand Up @@ -2508,7 +2508,7 @@ func godeep(it *lex.ItemIterator, gq *GraphQuery) error {
continue
} else if isExpandFunc(valLower) {
if varName != "" {
return x.Errorf("expand() cannot be used with a variable", val)
return x.Errorf("expand() cannot be used with a variable: %s", val)
}
if alias != "" {
return x.Errorf("expand() cannot have an alias")
Expand Down
10 changes: 5 additions & 5 deletions task/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ var (
)

func FromInt(val int) *intern.TaskValue {
bs := make([]byte, 4)
binary.LittleEndian.PutUint32(bs, uint32(val))
bs := make([]byte, 8)
binary.LittleEndian.PutUint64(bs, uint64(val))
return &intern.TaskValue{Val: []byte(bs), ValType: intern.Posting_INT}
}

func ToInt(val *intern.TaskValue) int32 {
result := binary.LittleEndian.Uint32(val.Val)
return int32(result)
func ToInt(val *intern.TaskValue) int64 {
result := binary.LittleEndian.Uint64(val.Val)
return int64(result)
}

func FromBool(val bool) *intern.TaskValue {
Expand Down

0 comments on commit 8cd1a2a

Please sign in to comment.