-
Notifications
You must be signed in to change notification settings - Fork 65
SWIFT-148: WriteConcern.description should return empty string on error #88
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
guard let jsonData = json else { | ||
return String() | ||
guard let json = bson_as_canonical_extended_json(self.data, nil) else { | ||
return "" |
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.
AFAIK, ""
is equivalent to String()
in this context. I opted for the string literal for consistency since I found no other uses of String()
in the driver.
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.
yes, I prefer the literal as well
let json = bson_as_canonical_extended_json(self.data, nil) | ||
guard let jsonData = json else { | ||
return String() | ||
guard let json = bson_as_canonical_extended_json(self.data, nil) else { |
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.
This seemed trivial to inline and avoid the extra constant declaration without adding too much width to the line.
} | ||
|
||
/// Returns a canonical extended JSON representation of this `Document` | ||
/// Returns the canonical extended JSON representation of this `Document`. | ||
/// On error, an empty string will be returned. |
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.
This documentation now consistent across both JSON accessors and all three description
accessors in the PR.
We can ignore ObjectId.description
since that never returns an error, nor does it have a doc comment (I suppose it's inherited from the protocol).
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
https://jira.mongodb.org/browse/SWIFT-148