Skip to content

Conversation

@patrickfreed
Copy link
Contributor

SWIFT-630

This PR updates the public API and tests to use the new BSON enum. As part of this, the following changes have been made:

  • The BSONValue protocol is now internal
  • Array conditionally conforms to BSONValue when Element == BSON
  • AnyBSONValue has been removed
  • bsonEquals and its associated Nimble matcher have been removed

Most of the implementation of the BSON library has remained the same with the exception of the encoder/decoder, which required some changes.

@patrickfreed patrickfreed marked this pull request as ready for review October 15, 2019 17:50
@patrickfreed patrickfreed requested a review from kmahar October 15, 2019 17:50
Copy link
Contributor

@kmahar kmahar left a comment

Choose a reason for hiding this comment

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

this looks great, and all the stuff you were able to rewrite / condense seems like further confirmation to me that this new API is the right choice. my comments are mostly nits and a few questions.

/// Decode a BSONValue type from this container for the given key.
private func decodeBSONType<T: BSONValue>(_ type: T.Type, forKey key: Key) throws -> T {
let entry = try getValue(forKey: key)
return try self.decoder.with(pushedKey: key) {
Copy link
Contributor

Choose a reason for hiding this comment

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

is still with(pushedKey:) thing still called on the new code paths that used to use this?

Copy link
Contributor Author

@patrickfreed patrickfreed Oct 16, 2019

Choose a reason for hiding this comment

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

it's still called in decodeNumber and decode(type:forKey).

Copy link
Contributor

Choose a reason for hiding this comment

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

what if you are decoding e.g. a Bool or a String (line 582, 597)? it seems to me like those can get called directly now without adding the key that is being decoded to the key path

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ohh, I misunderstood what you were saying. Yeah that's a very good point; I shouldn't be using an "unboxing" method to do "decoding". I've gone ahead and reverted removing this method and made the two examples you mentioned call it again.

@patrickfreed patrickfreed force-pushed the SWIFT-630/integrate-bson branch from 984c51a to 81f223d Compare October 16, 2019 20:58
@patrickfreed patrickfreed merged commit 4505c86 into master Oct 18, 2019
@patrickfreed patrickfreed deleted the SWIFT-630/integrate-bson branch October 18, 2019 22:23
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