Core Data: [Fixed] NSPredicate failing when using NSSQLiteStoreType
Core Data: [Fixed] NSPredicate failing when using NSSQLiteStoreType
- Subject: Core Data: [Fixed] NSPredicate failing when using NSSQLiteStoreType
- From: Yvan BARTHÉLEMY <email@hidden>
- Date: Tue, 5 May 2009 09:28:47 +0200
Hello,
In an entity A, I have a toMany relationship to an entity B named
relB. relB has a inverse toOne relationship relA.
NSFetchRequest *request = [[[NSFetchRequest alloc] init] autorelease];
[request setEntity:[NSEntityDescription entityForName:@"A"
inManagedObjectContext:moc]];
[request setPredicate:[NSPredicate predicateWithFormat:@"(relB ==
NIL) || (relB[SIZE] == 0)"]];
NSArray *objects = [moc executeFetchRequest:request error:&error];
Using NSSQLiteStoreType, this raises the following exception on
executeFetchRequest :
*** Terminating app due to uncaught exception
'NSInvalidArgumentException', reason: 'to-many key not allowed here'
Changing predicates raises other exceptions, but I couldn't make this
work. I need to switch from XML to SQLite because my model needs to
scale.
Here is the other variants I tried and their associated exceptions :
[request setPredicate:[NSPredicate
predicateWithFormat:@"self.relB[SIZE] = 0"]];
*** Terminating app due to uncaught exception
'NSInvalidArgumentException', reason: '*** -constantValue only defined
for abstract class. Define -[NSFunctionExpression constantValue]!'
[request setPredicate:[NSPredicate predicateWithFormat:@"relB[SIZE] =
0"]];
*** Terminating app due to uncaught exception
'NSInvalidArgumentException', reason: 'Unsupported function expression
displays[SIZE]'
[request setPredicate:[NSPredicate predicateWithFormat:@"displays ==
NIL"]];
*** Terminating app due to uncaught exception
'NSInvalidArgumentException', reason: 'to-many key not allowed here'
[request setPredicate:[NSPredicate
predicateWithFormat:@"self.displays == NIL"]];
*** Terminating app due to uncaught exception
'NSInvalidArgumentException', reason: 'to-many key not allowed here'
I don't really understand what can happen here. Any information would
be welcome.
For now, I am using -[NSArray filteredArrayUsingPredicate:] which
solves my problem. But I'm still wondering why I cannot do this using -
[NSFetchRequest setPredicate:].
Thanks,
Yvan BARTHÉLEMY_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden