Change default behavior of Int and Double decoding to not convert to native javascript Number #774
Labels
api: datastore
Issues related to the googleapis/nodejs-datastore API.
type: feature request
‘Nice-to-have’ improvement, new feature or different behavior or design.
Currently the
entityFromEntityProto
/decodeValueProto
method, which is used to cast datastore entities into Javascript objects, convertsDatastoreInt
andDatastoreDouble
toNumber
by default. While this was done to make the surface ergonomic for node programmers, there exists a case where a Double is indistinguishable from an int (3.0) in javascript. This results in a situation where a user changes a column type accidentally. Consider the followingThe final get, due to auto unboxing, will be an int as on the retrieval 4.0 is seen to be the number 4, which is uploaded as an int.
I think we should support configuring wrapNumbers, but moving to default it to wrapping seems sensible.
Also, doubles should have the same option available.
related to #773
The text was updated successfully, but these errors were encountered: