Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ adhere to [Semantic Versioning](https://semver.org) starting `v22.0.0`.

- **Fixed**
- fix(core): fix panic in verifyUniqueWithinMutation when mutation is conditionally pruned (#9450)
- fix(query): return full float value in query results (#9492)

## [v24.X.X] - YYYY-MM-DD

Expand Down
2 changes: 1 addition & 1 deletion query/fastjson_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func TestSubgraphToFastJSON(t *testing.T) {

t.Run("With a valid float result", func(t *testing.T) {
sg := subgraphWithSingleResultAndSingleValue(task.FromFloat(42.0))
assertJSON(t, `{"query":[{"val":42.000000}]}`, sg)
assertJSON(t, `{"query":[{"val":42}]}`, sg)
})

t.Run("With invalid floating points", func(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion query/outputnode.go
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,7 @@ func valToBytes(v types.Val) ([]byte, error) {
return nil, errors.New("Unsupported floating point number in float field")
}

return []byte(fmt.Sprintf("%f", f)), nil
return []byte(fmt.Sprintf("%g", f)), nil
case types.BoolID:
if v.Value.(bool) {
return boolTrue, nil
Expand Down
10 changes: 10 additions & 0 deletions query/outputnode_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -294,3 +294,13 @@ func TestMarshalTimeJson(t *testing.T) {
require.Equal(t, tc.out, string(out))
}
}

func TestMarshalFloat(t *testing.T) {
var (
in = types.Val{Tid: types.FloatID, Value: 0.123456789012345}
out = "0.123456789012345"
)
result, err := valToBytes(in)
require.NoError(t, err)
require.Equal(t, out, string(result))
}
Loading