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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to