-
Notifications
You must be signed in to change notification settings - Fork 926
Call toFirestore() only once #3755
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
Conversation
🦋 Changeset is good to goLatest commit: eea74f4 We got this. This PR includes changesets to release 8 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Binary Size ReportAffected SDKs
Test Logs |
validateExactNumberOfArgs('CollectionReference.add', arguments, 1); | ||
const convertedValue = this._converter | ||
? this._converter.toFirestore(value) | ||
: value; | ||
validateArgType('CollectionReference.add', 'object', 1, convertedValue); | ||
const docRef = this.doc(); | ||
return docRef.set(value).then(() => docRef); | ||
return ((docRef as unknown) as DocumentReference) | ||
.set(value, undefined, 'CollectionReference.add') | ||
.then(() => docRef); |
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.
Couldn't you just leave the original code as is and do:
return docRef.withConverter(defaultConverter).set(value).then(() => docRef)
?
6f2b338
to
fd3f5f5
Compare
.changeset/tame-donuts-relate.md
Outdated
'@firebase/firestore': patch | ||
--- | ||
|
||
Fixed a bug that where CollectionReference.add() called FirestoreDataConverter.toFirestore() twice intead of once (#3742). |
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.
Please fix grammar.
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.
done.
return snapshot.data(options)!; | ||
} | ||
}; | ||
return docRef |
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.
Can you just call the DocumentReference constructor here? That way you can pass "null" and don't need to specify a converter.
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.
Done.
Co-authored-by: Sebastian Schmidt <[email protected]>
Fixes #3742.