Reputation: 8969
Before I start let me give you how my data model looks like:
I then have a fetch request with the following predicate:
NSArray *allowedPackNames = @[@"success, happiness, free"];
self.fetchedResultsController = [Author MR_fetchAllGroupedBy:nil
withPredicate:[NSPredicate predicateWithFormat:@"ANY quotes.quote.pack.packName IN %@", allowedPackNames]
sortedBy:AuthorKeys.name
ascending:YES
delegate:self];
I wanted to fetch all Authors that has a Quote with packName of success or happiness or free. Author has a NSSet of quotes as you can see in the relationship table below. However when I execute this I get the following error:
CoreData: error: (1) I/O error for database at /Users/Abdul/Library/Application Support/iPhone Simulator/6.1/Applications/DA17421B-A54D-42E3-9694-FDCBFF7F8BA4/Library/Application Support/MyCoolApp/MyCoolApp.sqlite. SQLite error code:1, 'no such column: t2.ZQUOTE'
2013-04-05 15:26:47.175 MyCoolApp[78622:c07] Core Data: annotation: -executeRequest: encountered exception = I/O error for database at /Users/Aditya/Library/Application Support/iPhone Simulator/6.1/Applications/DA17421B-A54D-42E3-9694-FDCBFF7F8BA4/Library/Application Support/MyCoolApp/MyCoolApp.sqlite. SQLite error code:1, 'no such column: t2.ZQUOTE' with userInfo = {
NSFilePath = "/Users/Abdul/Library/Application Support/iPhone Simulator/6.1/Applications/DA17421B-A54D-42E3-9694-FDCBFF7F8BA4/Library/Application Support/MyCoolApp/MyCoolApp.sqlite";
NSSQLiteErrorDomain = 1;
}
Any idea why?
Upvotes: 1
Views: 316
Reputation: 539685
If I see it correctly, the predicate should be
[NSPredicate predicateWithFormat:@"ANY quotes.pack.packName IN %@", allowedPackNames]
i.e. you have to remove "quote", which is an attribute of the Quote entity, not a relationship.
Upvotes: 1