diff --git a/db/fetcher/versioned_test.go b/db/fetcher/versioned_test.go index d48ab16fd7..0e432f6365 100644 --- a/db/fetcher/versioned_test.go +++ b/db/fetcher/versioned_test.go @@ -347,7 +347,11 @@ func compareVersionedDocs(t *testing.T, doc, expected map[string]interface{}) { // make sure our floats are converted if f, ok := expected[k].(float64); ok { if f == float64(int64(f)) { - expected[k] = int64(f) + expected[k] = float64(f) + } + + if u, ok := v.(uint64); ok { + v = float64(u) } } @@ -356,6 +360,7 @@ func compareVersionedDocs(t *testing.T, doc, expected map[string]interface{}) { v = int64(i) } } + assert.Equal(t, expected[k], v) } } diff --git a/db/tests/query/one_to_many/with_group_test.go b/db/tests/query/one_to_many/with_group_test.go index 2b59be026b..094f4afdba 100644 --- a/db/tests/query/one_to_many/with_group_test.go +++ b/db/tests/query/one_to_many/with_group_test.go @@ -202,7 +202,7 @@ func TestQueryOneToManyWithParentJoinGroupNumber(t *testing.T) { "published": []map[string]interface{}{ { "name": "Histoiare des Celtes et particulierement des Gaulois et des Germains depuis les temps fabuleux jusqua la prise de Roze par les Gaulois", - "rating": uint64(2), + "rating": float64(2), }, }, }, diff --git a/db/tests/query/one_to_two_many/simple_test.go b/db/tests/query/one_to_two_many/simple_test.go index 11a1f9ad95..7dc1344ce2 100644 --- a/db/tests/query/one_to_two_many/simple_test.go +++ b/db/tests/query/one_to_two_many/simple_test.go @@ -309,7 +309,7 @@ func TestQueryOneToTwoManyWithNamedAndUnnamedRelationships(t *testing.T) { }, "price": map[string]interface{}{ "currency": "SEK", - "value": uint64(129), + "value": float64(129), }, }, { @@ -414,7 +414,7 @@ func TestQueryOneToTwoManyWithNamedAndUnnamedRelationships(t *testing.T) { { "name": "A Time for Mercy", "price": map[string]interface{}{ - "value": uint64(129), + "value": float64(129), }, }, { diff --git a/document/encoded.go b/document/encoded.go index 261fc21bca..5301445d47 100644 --- a/document/encoded.go +++ b/document/encoded.go @@ -87,6 +87,20 @@ func (e EncProperty) Decode() (core.CType, interface{}, error) { } val = stringArray } + } else { // CBOR often encodes values typed as floats as ints + switch e.Desc.Kind { + case base.FieldKind_FLOAT: + switch v := val.(type) { + case int64: + return ctype, float64(v), nil + case int: + return ctype, float64(v), nil + case uint64: + return ctype, float64(v), nil + case uint: + return ctype, float64(v), nil + } + } } return ctype, val, nil