Skip to content

Commit bc73ece

Browse files
authored
use internal _bson_get_len from swift C bson bindings
This method is introduced to overcome limitations around field access when `bson_t` is treated as an `OpaquePointer`.
1 parent 50f6686 commit bc73ece

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

Package.resolved

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ let package = Package(
66
.library(name: "MongoSwift", targets: ["MongoSwift"])
77
],
88
dependencies: [
9-
.package(url: "https://github.com/mongodb/swift-bson", from: "2.0.0"),
10-
.package(url: "https://github.com/mongodb/swift-mongoc", from: "2.0.0"),
9+
.package(url: "https://github.com/mongodb/swift-bson", .upToNextMajor(from: "2.0.0")),
10+
.package(url: "https://github.com/mongodb/swift-mongoc", .upToNextMajor(from: "2.0.0")),
1111
.package(url: "https://github.com/Quick/Nimble.git", from: "7.3.0")
1212
],
1313
targets: [

Sources/MongoSwift/BSON/Document.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,11 @@ extension Document {
284284
public var rawBSON: Data {
285285
// swiftlint:disable:next force_unwrapping - documented as always returning a value.
286286
let data = bson_get_data(self.data)!
287+
#if compiler(>=5.0)
288+
let length = _bson_get_len(self.data)
289+
#else
287290
let length = self.data.pointee.len
291+
#endif
288292
return Data(bytes: data, count: Int(length))
289293
}
290294

0 commit comments

Comments
 (0)