Fluent, Model, the ID property, and a Sendable warning

I've noticed a warning being kicked out when compiling my Model classes, for example:

Stored property '_id' of 'Sendable'-conforming class 'R2CombinedDiv' is mutable

...where the class is defined as:

final class R2CombinedDiv: Model {
  typealias IDValue = Int
  static let schema = "r2_combined_divs"

  @ID(custom: "combined_id", generatedBy: .user)
  var id: Int?
...

As I understand it, I need to define the ID property as optional so that Fluent can inflate it properly. So, I've been ignoring the warning for now, but I want to raise the question. Is this going to get dealt with somehow?

2 Likes

Actually, this is how Fluent deals with being Sendable conforming. You can check out the whole story here On Fluent Models and Sendable warnings | The Vapor Blog, but the TL;DR is you can safely use @unchecked Sendable on your model(s) to get rid of the warning

2 Likes