-
Notifications
You must be signed in to change notification settings - Fork 147
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
fix: return null for 'parent' call on root collection #1099
Conversation
404680f
to
e84dc2f
Compare
Codecov Report
@@ Coverage Diff @@
## master #1099 +/- ##
==========================================
- Coverage 97.61% 97.48% -0.13%
==========================================
Files 27 27
Lines 16970 16974 +4
Branches 1351 1270 -81
==========================================
- Hits 16565 16547 -18
- Misses 402 423 +21
- Partials 3 4 +1
Continue to review full report at Codecov.
|
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. Wouldn't this be considered a breaking change since users would have to check that their .parent
call isn't null now?
get parent(): DocumentReference<DocumentData> { | ||
return new DocumentReference(this.firestore, this._queryOptions.parentPath); | ||
get parent(): DocumentReference<DocumentData> | null { | ||
if (this._queryOptions.parentPath.isDocument) { |
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.
s/isDocument/isDocument()
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.
isDocument
is a property (typed a get isDocument()
). As such, no parenthesis are needed.
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.
Thanks for the review. Fortunately, this is not a breaking change:
- The method is already typed to return null (in the firestore.d.ts types). I will also update the JSDoc.
- This caused an "NPE" in our code before, so this was already broken (that's the issue that was filed).
We need to return "null" for the parent call in a root collection.
Also noticed that our Path.isEqual doesn't work correctly since it considers QualifiedResourcePaths and ResourcePaths as non-equal. Our typings already ensure that a FieldPath and a ResourcePath can never be compared for equality.
Fixes #1098