orlandos-nl / MongoKitten

Native MongoDB driver for Swift, written in Swift

Home Page:https://orlandos.nl/docs/mongokitten/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cannot decode `[Date]` from Codable model

grahamburgsma opened this issue · comments

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

@grahamburgsma what's your BSON version?

what's your BSON version?

@Joannis It is 8.0.1.

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

It might also affect other specific generics

8.0.2 has fixed it, thanks for the quick support!