Skip to content

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

Merged
merged 2 commits into from
Jul 9, 2018
Merged

SWIFT-148: WriteConcern.description should return empty string on error #88

merged 2 commits into from
Jul 9, 2018

Conversation

jmikola
Copy link
Member

@jmikola jmikola commented Jul 6, 2018

@jmikola jmikola requested review from mbroadst and kmahar July 6, 2018 21:23
guard let jsonData = json else {
return String()
guard let json = bson_as_canonical_extended_json(self.data, nil) else {
return ""
Copy link
Member Author

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.

Copy link
Contributor

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 {
Copy link
Member Author

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.
Copy link
Member Author

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).

Copy link
Member

@mbroadst mbroadst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jmikola jmikola merged commit 32b8ea4 into mongodb:master Jul 9, 2018
@jmikola jmikola deleted the swift-148 branch July 9, 2018 13:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants