Re: predicate for a Core Data fetch request rejected by SQL
Re: predicate for a Core Data fetch request rejected by SQL
- Subject: Re: predicate for a Core Data fetch request rejected by SQL
- From: Joanna Carter <email@hidden>
- Date: Sat, 6 Mar 2010 09:59:08 +0000
Hi Mark
> Thanks all for the sharing of thoughts. Glad someone could confirm that what I was attempting did not make sense from the SQL perspective (which I am a newbie to). But, like Sean wrote, Core Data seems to be presented as an abstraction ABOVE the layer which implements the actual storage/retrieval, thus, having to know about SQL details to get a Core Data operation to execute properly is unfortunate.
> ... The only expanded discussion I can find on this subject in the official docs is, "predicates that rely on Cocoa cannot work", which, for me, does not shed enough light on the subject.
It is easy for someone like me to understand differences between how predicates work, because I have spent the last five years writing object persistence frameworks, which use predicates. However, it is another thing to explain that well founded knowledge to someone else who has never come across the concept :-)
This quote from the Core Data Programming Guide:
////////////////////
There are some interactions between fetching and the type of store. In the XML, binary, and in-memory stores, evaluation of the predicate and sort descriptors is performed in Objective-C with access to all Cocoa's functionality, including the comparison methods on NSString. The SQL store, on the other hand, compiles the predicate and sort descriptors to SQL and evaluates the result in the database itself. This is done primarily for performance, but it means that evaluation happens in a non-Cocoa environment, and so sort descriptors (or predicates) that rely on Cocoa cannot work.
////////////////////
To my mind, this does state exactly what you have found.
I suppose all my experience has come from only ever writing predicate hierarchies against SQL storage mechanism, therefore I have only ever included predicate types that can be translated, primarily, into SQL.
However, it is possible to use my "SQL" predicates against lists of objects but, obviously, not in such a comprehensive manner as the Cocoa-based extensions that Apple have provided.
In my experience, as a consultant to companies who write business management software, the developers tend to come from a SQL background and, therefore, are quite surprised that a predicate hierarchy can cope with what they expect from an RDBMS. You, on the other hand, seem to have come from "the other side" where your experience started with XML and other non-SQL data storage. Therefore, you perceive the limitations of the SQL "subset" as a disadvantage.
Maybe, one day, SQL parsers will be as comprehensive as the Cocoa ones :-)
Joanna
--
Joanna Carter
Carter Consulting
_______________________________________________
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