Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion query/outputnode.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"bytes"
"encoding/json"
"fmt"
"math"
"sort"
"strconv"
"strings"
Expand Down Expand Up @@ -138,7 +139,15 @@ func valToBytes(v types.Val) ([]byte, error) {
case types.IntID:
return []byte(fmt.Sprintf("%d", v.Value)), nil
case types.FloatID:
return []byte(fmt.Sprintf("%f", v.Value)), nil
f, fOk := v.Value.(float64)

// +Inf, -Inf and NaN are not representable in JSON.
// Please see https://golang.org/src/encoding/json/encode.go?s=6458:6501#L573
if !fOk || math.IsInf(f, 0) || math.IsNaN(f) {
return nil, errors.New("Unsupported floating point number in float field")
}

return []byte(fmt.Sprintf("%f", f)), nil
case types.BoolID:
if v.Value.(bool) {
return []byte("true"), nil
Expand Down