Moved from GitHub dgo/66
Posted by jvsteiner:
Since the mutation input is in JSON format which doesn’t differentiate between INT/FLOAT (everything is a number), the server gets a float and stores the facet as such. This is, unfortunately, a limitation of the JSON format and the fact that facets don’t have a fixed type.
I would recommend setting a property on a node (instead of facet) if the type is important to you or using the RDF mutation format.
Originally posted by @pawanrawal in Bug: Mutation issue with facets integer · Issue #3 · dgraph-io/dgo · GitHub
This seems like a more general problem affecting node predicates as well. It seems at the moment, the only choices are:
- use mutation JSON, in which case I can’t get my integers back out of the database, because they get converted to floats during unmarshalling
NQuads and construct them myself.
In my use case, I have dynamic data, and I don’t know what it looks like ahead of time, so I cannot unmarshal into a predefined struct.
I think a modified json.Unmarshaler which does not coerce ints might be helpful. Perhaps the standard lib code could be repurposed and modified relatively easily…