[go: nahoru, domu]

Skip to content
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

Firestore negative zero (-0) is stored as integerValue instead of doubleValue #1638

Closed
Yonom opened this issue Dec 1, 2021 · 3 comments · Fixed by #1639
Closed

Firestore negative zero (-0) is stored as integerValue instead of doubleValue #1638

Yonom opened this issue Dec 1, 2021 · 3 comments · Fixed by #1639
Assignees
Labels
api: firestore Issues related to the googleapis/nodejs-firestore API.

Comments

@Yonom
Copy link
Contributor
Yonom commented Dec 1, 2021

This issue is about an inconsistency between the firestore JS SDK and the nodejs SDK. Firestore JS SDK stores negative zero (-0) has a double value with the correct sign. The NodeJS SDK does not do so. This leads to loss of data (the number's sign) as well as some odd behavior when trying to query documents saved from the JS SDK based on -0.

Environment details

  • OS: macOS
  • Node.js version: 16.13
  • npm version: 8.1
  • @google-cloud/firestore version: 4.15.1

Steps to reproduce

  1. write negative zero to a document
await firestore.collection('test').doc('test').set({ number: -0 })
  1. read the document and ensure the value is negative zero
const doc = await firestore.collection('test').doc('test').get();
const expectedToBeNegativeZero = doc.data().number;
console.assert(Object.is(expectedToBeNegativeZero, -0))

Firebase Web SDK: ✅ Works as expected
Firebase Node.JS SDK: ❌ Value is 0 instead of -0

@product-auto-label product-auto-label bot added the api: firestore Issues related to the googleapis/nodejs-firestore API. label Dec 1, 2021
@dconeybe dconeybe self-assigned this Dec 1, 2021
@dconeybe
Copy link
Contributor
dconeybe commented Dec 1, 2021

Hi @Yonom. Thanks for the report. I'll take a look into it.

@Yonom
Copy link
Contributor Author
Yonom commented Dec 1, 2021

@dconeybe thanks, I have also submitted a PR with a fix 👍

@yoshi-automation yoshi-automation added the triage me I really want to be triaged. label Dec 2, 2021
@dconeybe dconeybe removed the triage me I really want to be triaged. label Dec 2, 2021
@dconeybe
Copy link
Contributor
dconeybe commented Dec 7, 2021

FYI: Your fix has been released in version 5.0.1 at https://www.npmjs.com/package/@google-cloud/firestore

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: firestore Issues related to the googleapis/nodejs-firestore API.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants