I'm trying to fetch some results with the new #Predicate macro. The problem appears when I try to use an enum property inside the predicate. Does anyone know if it can be done or if this is a bug?
XCode 15 beta 4
Fetch 1:
let predicate = #Predicate<ModelA> { $0.type == ModelA.ModelAType.a }
Fetch 2:
let predicate = #Predicate<ModelA> { $0.type.rawValue == ModelA.ModelAType.a.rawValue }
Model:
@Model final class ModelA: Codable {
@Attribute(.unique) var id: Int64 = 0
enum ModelAType: Int, CaseIterable, Codable { case a = 1, b }
var type: ModelAType = ModelAType.a
}
Errors:
Type 'ModelA.Type' cannot conform to 'StandardPredicateExpression'
Type 'ModelA.Type' cannot conform to 'PredicateExpression'
Cannot infer key path type from context; consider explicitly specifying a root type