-
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
feat: support BigInt #1016
feat: support BigInt #1016
Conversation
Codecov Report
@@ Coverage Diff @@
## node10 #1016 +/- ##
=======================================
Coverage 98.54% 98.54%
=======================================
Files 25 25
Lines 16614 16620 +6
Branches 1258 1255 -3
=======================================
+ Hits 16372 16379 +7
+ Misses 239 238 -1
Partials 3 3
Continue to review full report at Codecov.
|
4d73dd3
to
6b847b6
Compare
6b847b6
to
e8d9e4f
Compare
e8d9e4f
to
2acfb25
Compare
@@ -83,15 +83,15 @@ PBJS_ARGS=( --proto_path=. \ | |||
--no-decode \ | |||
--no-verify \ | |||
--no-delimited \ | |||
--force-enum-string \ | |||
--force-number) | |||
--force-enum-string) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was not able to get the ProtobufJS compiler to use "string|number" in its types. It only offers "Long", "Long|number" and "number". So I chose to use "Long|number" and replace it manually with "string|number". int32 (like nanoseonds) are not affected since they can be represented as number.
@@ -177,16 +177,12 @@ export function valueFromJson(fieldValue: api.IValue): api.IValue { | |||
return { | |||
bytesValue: bytesFromJson(fieldValue.bytesValue!), | |||
}; | |||
case 'integerValue': |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dropped this since the client supports "string|number" throughout. Converting to Number results in precision loss.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
* Whether to use `BigInt` for integer types when deserializing Firestore | ||
* Documents. Regardless of magnitude, all integer values will be returned as | ||
* `BigInt` to match the precision of the Firestore backend. Floating point | ||
* numbers continue to use JavaScript's `number` type. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe s/continue to/will for consistent future tense?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Opted to change this to present tense for both.
|
||
constructor(firestore: Firestore) { | ||
// Instead of storing the `firestore` object, we store just a reference to | ||
// its `.doc()` method. This avoid a circular reference, which breaks | ||
// JSON.stringify(). | ||
this.createReference = path => firestore.doc(path); | ||
this.createInteger = n => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we validate the string so that Number(n)
won't break on bad inputs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These values come from the backend and IIRC any issues with it so far (we already used this code below). Opting not do this for now.
* fix!: mark v1beta1 client as deprecated (#937) * feat!: use QueryDocumentSnapshot in FirestoreDataConverter (#965) * deps: update to gts 2.x (#1013) * chore!: update settings for Node 10 (#1019) * deps: drop through2 (#1014) * feat: support BigInt (#1016) * fix: make update.sh work on Linux (#1043) * fix: only use BigInt in BigInt system test (#1044) * fix: make pbjs compile admin proto again (#1045) * Add BulkWriter (#1055) * docs: Add documentation for FirestoreDataConverter (#1059) * chore: enforce return types (#1065) * fix: add generic to Firestore.getAll() (#1066) * chore: remove internal WriteOp (#1067) * chore: add linter checks for it|describe.only (#1068) * fix: handle terminate in BulkWriter (#1070) * chore: run template copying last in synthtool (#1071) * feat: Firestore Bundles implementation (#1078) * feat: add support for set() with SetOptions when using FirestoreDataConverter (#1087) * feat: Add totalDocuments and totalBytes to bundle metadata. (#1085) * feat: Add totalDocuments and totalBytes to bundle metadata. * fix: Better comment * fix: Better testing. * fix: Improve metadata testing. * fix: incomplete expect in rate-limiter test (#1092) * Remove BatchWrite proto, fix conformance tests * chore: use public API types internally (#1100) * feat: add Partition and BatchWrite protos (#1110) * fix: remove GCF transaction fallback (#1112) * fix: add BulkWriter integration tests, java backport changes, delete fix (#1117) * chore: merge master (#1218) * chore: add eslint check for console.log statements (#1229) * fix: another attempt at fixing the flaky BulkWriter test (#1228) * Fix comment * Renames * Test fix * Fix unit tests Co-authored-by: Brian Chen <[email protected]> Co-authored-by: wu-hui <[email protected]>
This PR adds support for serializing to BigInt and for deserializing to BigInt (optional, via flag). We still need to settle on a flag name.
Fixes #872