Predicate based on the relationship

I am trying to use SwiftData to perform a Query based on the name of the actor, which is inside a movie model. Here is the Movie model. @Model final class Movie {

var title: String
var year: Int

@Relationship(.noAction, inverse: \Actor.movies)
var actors: [Actor] = []

init(title: String, year: Int) {
    self.title = title
    self.year = year
}

} Here is my actual Query:

 _movies = Query(filter: #Predicate { $0.actors.contains(where: { $0.name.contains(actorName) }) })

But it returns nothing, even though I am passing actorName which exists in the movie.

Do the query and data case match? It doesn’t currently support case insensitive queries. A major oversight on their part. I filed a bug and you should too if this is your issue. If the issue is the relationship, you should file that too.

Thanks! Yes. I checked the casing and I made sure that the actorName is associated with a movie.

With CoreData, I'm able to create fetchRequest based on relationship, for example, fetch all items belong to given box

let fetchRequest: NSFetchRequest<Item> = Item.fetchRequest()
fetchRequest.predicate = NSPredicate(format: "box == %@", box)

but it is not possible with Predicate

let predicate = #Predicate<Item> { item in
    return item.box == box
}

I wonder, Is there any solution for this?

Predicate based on the relationship
 
 
Q