Cannot decode `[Date]` from Codable model
grahamburgsma opened this issue · comments
Graham Burgsma commented
Describe the bug
Cannot decode [Date]
from Codable model. In my case the query is done through an aggregate pipeline.
To Reproduce
struct SomeModel: Codable {
let dates: [Date]
}
let aggregate = req.mongoDB["somecollection"].buildAggregate { ... }
let results = try await aggregate.decode(SomeModel.self).drain()
What happens
Error is thrown: [ WARNING ] BSONTypeConversionError<Primitive>(from: 2022-08-24 18:09:46 +0000, to: Swift.Double)
.
Server-side Swift:
- OS: macOS
- Swift Version: 5.7
- MongoKitten Version: 7.2.1
Joannis Orlandos commented
@grahamburgsma what's your BSON version?
Graham Burgsma commented
what's your BSON version?
@Joannis It is 8.0.1.
Joannis Orlandos commented
Can you update that to 8.0.2? There's a known bug in BSON when using Dates within a property wrapper on 8.0.1
Joannis Orlandos commented
It might also affect other specific generics
Graham Burgsma commented
8.0.2 has fixed it, thanks for the quick support!