Can't query for the existence of an optional to-one relationship?

Hi,

say in my model I have members and each member optionally can have a relationship to a Club. So the relationship in the Member entity would be modelled like so: @Relationship(.nullify, inverse: \Club.members) var club: Club?

Now I would like to fetch al Members with no Club relationship. I would assume that this would work with a predicate like this:

let noClubPred = #Predicate<Member> { member in
   member.club == nil
}

Unfortunately this gives me the following error when compiling: Generic parameter 'RHS' could not be inferred.

Has anybody an idea how to phrase this predicate correctly, or is this a beta issue and it should actually work?

Thank you!

Cheers, Michael

Post not yet marked as solved Up vote post of milutz Down vote post of milutz
861 views

Replies

The same here

Does

let nilClub: Club? = nil
let noClubPred = #Predicate<Member> { member in 
    member.club == nilClub
}

work?