Skip to content

Conversation

@patrickfreed
Copy link
Contributor

SWIFT-882

This PR converts the extJSON computed properties to methods, since they may be computationally expensive. @mbroadst noted that they would be superseded by ExtendedJSONEncoder, and that we would probably deprecate them once that was introduced. Since these produce Strings, they could perhaps be useful as conveniences over invoking the encoder, so I also added "String" as a suffix to their method names.

These changes are not release blockers, but if we do want to make them we need to do so today, so I just put up the PR now to get the discussion rolling.

@codecov-commenter
Copy link

Codecov Report

Merging #496 into master will increase coverage by 0.02%.
The diff coverage is 97.56%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #496      +/-   ##
==========================================
+ Coverage   76.69%   76.71%   +0.02%     
==========================================
  Files         127      127              
  Lines       13144    13157      +13     
==========================================
+ Hits        10081    10094      +13     
  Misses       3063     3063              
Impacted Files Coverage Δ
Tests/BSONTests/BSONCorpusTests.swift 87.50% <85.71%> (ø)
Sources/MongoSwift/BSON/BSONDocument.swift 88.36% <100.00%> (ø)
Sources/TestsCommon/CommonTestUtils.swift 66.86% <100.00%> (ø)
Tests/BSONTests/CodecTests.swift 99.84% <100.00%> (+<0.01%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7e77a3d...a0a61bf. Read the comment docs.

/// Returns the relaxed extended JSON representation of this `BSONDocument`.
/// On error, an empty string will be returned.
public var extendedJSON: String {
public func toExtendedJSONString() -> String {
Copy link
Contributor

Choose a reason for hiding this comment

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

I was going to say it would be better to throw than to return an empty string now that these are methods, but OTOH i think in the new library we don't expect JSON serialization to fail unless it's explicitly unvalidated BSON. in which case i think fatal error / empty string is acceptable

@patrickfreed patrickfreed merged commit b6401f2 into mongodb:master Jun 4, 2020
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