Reputation: 833
I have a to-many relationship in my data model, and I'd like to get all the objects that have no corresponding objects in the relationship. For example:
Customer -> Purchases
I want to get all Customers that have 0 Purchases.
I've read somewhere that I could use "Purchases[SIZE] = 0", but this gives me an unsupported function expression error, which I think means it doesn't work with a SQLite backing store (which I don't want to switch from, due to some performance constraints).
Any ideas?
Upvotes: 0
Views: 1012
Reputation: 7084
The documentation says that either should work, but the former (Purchases[SIZE] == 0) does not. A bug has been filed.
Note that using the @count operator is going to use a JOIN as an implementation detail which may not have the performance characteristics you desire/require.
Upvotes: 0
Reputation: 833
I found the answer elsewhere, here it is for future use. Tested on iPhone OS 3.0.
[NSPredicate predicateWithFormat:@"Purchases.@count == 0"];
Upvotes: 5