Skip to content

Commit

Permalink
Merge pull request #154 from tayloraswift/upgrade-swift-bson
Browse files Browse the repository at this point in the history
upgrade swift-bson dependency
  • Loading branch information
tayloraswift authored Dec 24, 2024
2 parents e086ce7 + dd88766 commit 0cde67d
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 6 deletions.
6 changes: 3 additions & 3 deletions Package.resolved
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"originHash" : "c3e65bcdf275cab11159accb0efc9ac649418a02d521281bfe32fd24dd5884b0",
"originHash" : "69fb22e4ec8d46b7c22e5440a27556e8796a96b3d7617e8b91d8981bd71bea42",
"pins" : [
{
"identity" : "swift-atomics",
Expand All @@ -15,8 +15,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/tayloraswift/swift-bson",
"state" : {
"revision" : "0fa36cdaa0daa71d198cd0e0787959b664c098a2",
"version" : "0.3.1"
"revision" : "32814c943ab68fa50c01cc52fb8640a8f55cb3cd",
"version" : "0.4.0"
}
},
{
Expand Down
12 changes: 9 additions & 3 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ let package:Package = .init(name: "swift-mongodb",
],
dependencies: [
.package(url: "https://github.com/tayloraswift/swift-bson", .upToNextMinor(
from: "0.3.0")),
from: "0.4.0")),
.package(url: "https://github.com/tayloraswift/swift-grammar", .upToNextMinor(
from: "0.4.0")),
.package(url: "https://github.com/tayloraswift/swift-hash", .upToNextMinor(
Expand All @@ -34,6 +34,12 @@ let package:Package = .init(name: "swift-mongodb",
from: "2.28.0"),
],
targets: [
.target(name: "BSON_OrderedCollections",
dependencies: [
.product(name: "BSON", package: "swift-bson"),
.product(name: "OrderedCollections", package: "swift-collections"),
]),

.target(name: "OnlineCDF"),

.target(name: "SCRAM",
Expand Down Expand Up @@ -84,13 +90,13 @@ let package:Package = .init(name: "swift-mongodb",

.target(name: "MongoDriver",
dependencies: [
.target(name: "BSON_OrderedCollections"),
.target(name: "MongoCommands"),
.target(name: "MongoConfiguration"),
.target(name: "MongoExecutor"),
.target(name: "MongoLogging"),
.target(name: "SCRAM"),
.target(name: "UnixTime_Atomics"),
.product(name: "BSON_OrderedCollections", package: "swift-bson"),
.product(name: "BSON_UUID", package: "swift-bson"),
.product(name: "Atomics", package: "swift-atomics"),
.product(name: "SHA2", package: "swift-hash"),
Expand Down Expand Up @@ -118,11 +124,11 @@ let package:Package = .init(name: "swift-mongodb",

.target(name: "MongoQL",
dependencies: [
.target(name: "BSON_OrderedCollections"),
.target(name: "MongoBuiltins"),
.target(name: "MongoCommands"),
.product(name: "BSON", package: "swift-bson"),
.product(name: "BSONReflection", package: "swift-bson"),
.product(name: "BSON_OrderedCollections", package: "swift-bson"),
.product(name: "BSON_UUID", package: "swift-bson"),
]),

Expand Down
39 changes: 39 additions & 0 deletions Sources/BSON_OrderedCollections/OrderedDictionary (ext).swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import BSON
import OrderedCollections

extension OrderedDictionary:@retroactive BSONDecodable
where Key == BSON.Key, Value:BSONDecodable
{
@inlinable public
init(bson:BSON.AnyValue) throws
{
try self.init(bson: try .init(bson: consume bson))
}
@inlinable public
init(bson:BSON.Document) throws
{
self.init()
try bson.parse
{
(field:BSON.FieldDecoder<BSON.Key>) in

if case _? = self.updateValue(try field.decode(to: Value.self),
forKey: field.key)
{
throw BSON.DocumentKeyError<BSON.Key>.duplicate(field.key)
}
}
}
}
extension OrderedDictionary:@retroactive BSONDocumentEncodable, @retroactive BSONEncodable
where Key == BSON.Key, Value:BSONEncodable
{
@inlinable public
func encode(to bson:inout BSON.DocumentEncoder<BSON.Key>)
{
for (key, value):(Key, Value) in self.elements
{
bson[key] = value
}
}
}

0 comments on commit 0cde67d

Please sign in to comment.