Skip to content

Instantly share code, notes, and snippets.

@Obbut
Last active April 4, 2018 12:36
Show Gist options
  • Save Obbut/d7b465203c16399e2d2b8901aebea4b3 to your computer and use it in GitHub Desktop.
Save Obbut/d7b465203c16399e2d2b8901aebea4b3 to your computer and use it in GitHub Desktop.
BSON crash
import BSON
struct Henk : Codable {
struct Location : Codable {
var name = "JFdkljfds"
var street = "Harrieboblaan 1"
var postalCode = "1234 AB"
}
var _id = ObjectId()
var description: String? = nil
var location = Location()
}
let encoder = BSONEncoder()
var document = try! encoder.encode(Henk())
document["location", "name"] = nil
document["location", "street"] = nil
// Error while parsing BSON document: element type unknown at position 51.
// Doesn't happen when you create a new Document with the same data – probably a caching issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment