-
Notifications
You must be signed in to change notification settings - Fork 149
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
64-bit integers lose precision #872
Comments
@MegaByte Thanks for reporting. This is currently working as intended. We rely on the Number semantics of JavaScript. We may evaluate adding support for |
@schmidt-sebastian It's not only about precision. Currently, it's absolutely impossible to even learn that the fields stored in database is actually an Integer, or write an Integer to a database. I believe that it's an officially supported to access Firestore database from multiple platforms. For example, when I'm developing a mobile app in Flutter (Dart) and want to provide some backend logic for it, isn't it an supported, or even encouraged, solution to use Google Cloud Functions with Javascript SDK? When my application stores an Integer field in the database, how am I supposed to update it / export it? It's beyond inconvenient. It makes a simple task impossible. At very least, you could box all Integers with a helper |
We are working on dropping Node 8 support across all GCloud SDKs. Once Firestore has been migrated, we can add support for Node 10's BigInt. Note that we are offering Server SDKs in 7 different languages and are using idiomatic number types on all platforms. While not ideal, if you need help now, you may be better off using a language environment that supports full integer precision by default. |
The other problem is that the official admin interface also uses this library, which makes it literally impossible to manage that data properly if you don't have another way to access it, and it produces the inaccurate data silently. |
@MegaByte You mean the web console? You are absolutely right, it's also unacceptable that the official web interface isn't able to show what type the field really is or not able to produce a variable of certain type. Actually, I made an issue about it a few days ago: |
This has been merged, but won't be released until we push our next major version. |
That's great news, thank you! When this is released, could you please ping the team responsible for the Web Console, so they can use it to display/edit the Int64 data type? |
We haven't yet committed to fixing this in the Console. While I agree that losing precision is a major problem here as well, the solution is not as straightforward as BigInt support is still not widely available in the browsers we target. |
This is part of the 4.0.0 release, which will go out momentarily. You may enable this using the |
Is there a way to use this in "firebase-admin" |
Environment details
Steps to reproduce
5248794116772919364
and larger values)orderBy
keyed on that field with astartAfter
value > 2^53 (e.g.5248794116772919364
)Actual results:
5248794116772919000
.5248794116772919364
value is returned (with5248794116772919000
as above).Expected results:
5248794116772919364
value should not be returned.In addition, it is not possible to use an alternate type to avoid the numeric rounding. Using a
string
instartAfter
results in no data returned at all. Using aBigInt
(Node 10 only) gives the error:See also protocolbuffers/protobuf#3666
The text was updated successfully, but these errors were encountered: