You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi! There is a problem with .where expressions in case you are trying to filter toManyRelationship properties. In my code example I want to fetch all Master's which contains Pet with name Spot.
Code example:
final class Master: CoreStoreObject {
@Field.Relationship("pets")
var pets: [Pet]
}
final class Pet: CoreStoreObject {
@Field.Stored("name")
var name: String = ""
@Field.Relationship("master", inverse: \.$pets)
var master: Master?
}
func fetch() {
let itWorks = From<Pet>()
.where((\.$master ~ \.$pets ~ \.$name).any() == "Spot") // It doesn't reproduce any compiler errors
let itDoesntWork = From<Master>()
.where((\.$pets ~ \.$name).any() == "Spot") // Compiler errors:
// Operator function '~' requires that '[Pet]' conform to 'FieldRelationshipToOneType'
// Operator function '~' requires that 'FieldContainer<Pet>.Stored<String>' conform to 'ToManyRelationshipKeyPathStringConvertible'
}
Seems like a common case, so maybe I'm doing something wrong?
The text was updated successfully, but these errors were encountered:
Hi! There is a problem with
.where
expressions in case you are trying to filter toManyRelationship
properties. In my code example I want to fetch allMaster
's which containsPet
with name Spot.Code example:
Seems like a common case, so maybe I'm doing something wrong?
The text was updated successfully, but these errors were encountered: