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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: save negative zero as doubleValue #1639

Merged
merged 4 commits into from
Dec 2, 2021
Merged

fix: save negative zero as doubleValue #1639

merged 4 commits into from
Dec 2, 2021

Conversation

Yonom
Copy link
Contributor

@Yonom Yonom commented Dec 1, 2021

Why?

Javascript only has a number type while firestore differentiates between int64 and double. Both the Web SDK and the nodejs SDK identify integers to store them appropriately. However, the algorithms between the Web SDK and the nodejs SDK differ in one particular case: the negative zero double value.

Relevant lines of code from the JS SDK:
https://github.com/firebase/firebase-js-sdk/blob/master/packages/firestore/src/remote/number_serializer.ts#L56
https://github.com/firebase/firebase-js-sdk/blob/master/packages/firestore/src/util/types.ts#L44

This PR aligns the nodejs SDK behavior with the one in the Web SDK.

Template

Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:

  • Make sure to open an issue as a bug/issue before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea
  • Ensure the tests and linter pass
  • Code coverage does not decrease (if any source code was changed)
  • Appropriate docs were updated (if necessary)

Fixes #1638 馃

@Yonom Yonom requested review from a team as code owners December 1, 2021 19:23
@google-cla google-cla bot added the cla: no This human has *not* signed the Contributor License Agreement. label Dec 1, 2021
@product-auto-label product-auto-label bot added the api: firestore Issues related to the googleapis/nodejs-firestore API. label Dec 1, 2021
@dconeybe
Copy link
Contributor

dconeybe commented Dec 1, 2021

Thanks for the PR! Could you (a) sign the CLA (see CONTRIBUTING.md) and (b) add a test for this case to dev/test/document.ts?

@dconeybe dconeybe self-assigned this Dec 1, 2021
@google-cla google-cla bot added cla: yes This human has signed the Contributor License Agreement. and removed cla: no This human has *not* signed the Contributor License Agreement. labels Dec 1, 2021
@Yonom Yonom changed the title Save negative zero as doubleValue fix: save negative zero as doubleValue Dec 1, 2021
@dconeybe
Copy link
Contributor

dconeybe commented Dec 1, 2021

You can ignore the "Auto-approve.yml check" failed check.

This looks good to me, but I'm going to get my colleague with more experience in this particular GitHub repository to provide formal approval.

Thanks for taking the time to submit this fix!

@dconeybe
Copy link
Contributor

dconeybe commented Dec 1, 2021

@schmidt-sebastian Can you take a look at this PR? It LGTM but wanted a 2nd opinion.

@Yonom
Copy link
Contributor Author

Yonom commented Dec 1, 2021

Awesome. Thank you for the quick review! 馃槉

@schmidt-sebastian schmidt-sebastian added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Dec 1, 2021
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Dec 1, 2021
@schmidt-sebastian schmidt-sebastian added the owlbot:run Add this label to trigger the Owlbot post processor. label Dec 2, 2021
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Dec 2, 2021
@dconeybe dconeybe merged commit a6ba5cc into googleapis:main Dec 2, 2021
@Yonom Yonom deleted the negative-zero-fix branch December 2, 2021 17:41
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. cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Firestore negative zero (-0) is stored as integerValue instead of doubleValue
4 participants