This is the relevant part of my object graph:
Store <-->> Gift <<--> Person <<-->> Tag
I'd like to be able to filter the stores by the tag.filtering attribute, like this:
ANY gifts.person.tags.filtering == YES
But I understand why this doesn't work, due to the restriction to one to-many keys. So I am trying to use a set of nested SUBQUERY predicates, like this:
NSPredicate* filterPredicate = [NSPredicate predicateWithFormat:
@"(0 != SUBQUERY(gifts, $x,
(0 != SUBQUERY($x.person.tags, $y, $y.filtering==YES).@count)).@count)"];
This fails at runtime with an error:
"SQLite error code:1, 'no such column: t3.ZFILTERING'"
It seems like I'm on the right track, here, but can't find any other examples that use the same syntax. What am I missing?
From my comment above:
[NSPredicate predicateWithFormat:@"SUBQUERY(gifts, $x, ANY $x.person.tags.filtering == YES).@count != 0"]
works, and is even simpler than a nested SUBQUERY.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With