Core Data, SQL stores, and predicate restrictions

  • Hi all,

    After reading the docs and archives, it is clear to me now that with
    Core Data's SQL store one is more limited in the types of predicates one
    can use with fetches.

    What I can't find is a list of what I can and can't do.  The best I
    found was "[the] SQL store, on the other hand, compiles the predicate
    [...] to SQL and evaluates the result in the database itself. [...] it
    means that evaluation happens in a non-Cocoa environment, and so sort
    descriptors (or predicates) that rely on Cocoa cannot work".  How do I
    know if my predicate "relies on Cocoa"?

    For example, given the Employees/Departments scenario: if I try to fetch
    all employees that are in exactly 2 departments I use a fetch predicate
    of "departments[SIZE] == 2" which works great everywhere except with the
    SQL store.  I learnt this the hard way.

    Thanks,

    --
    ____________________________________________________________
    Sean McBride, B. Eng                <sean...>
    Rogue Research                        www.rogue-research.com
    Mac Software Developer              Montréal, Québec, Canada
  • HI Sean,

    One example would be if you have a method that calculates a value.
    That value would not be in the DB so the compiled predicate (if it
    would even compile) would not work because there is not column
    corresponding to your calc'd value.

    I think this is worth filing a bug against the docs to clear that up.

    HTH,

    -bd-
    http://bill.dudney.net/roller/objc

    On May 16, 2008, at 3:50 PM, Sean McBride wrote:

    > Hi all,
    >
    > After reading the docs and archives, it is clear to me now that with
    > Core Data's SQL store one is more limited in the types of predicates
    > one
    > can use with fetches.
    >
    > What I can't find is a list of what I can and can't do.  The best I
    > found was "[the] SQL store, on the other hand, compiles the predicate
    > [...] to SQL and evaluates the result in the database itself. [...] it
    > means that evaluation happens in a non-Cocoa environment, and so sort
    > descriptors (or predicates) that rely on Cocoa cannot work".  How do I
    > know if my predicate "relies on Cocoa"?
    >
    > For example, given the Employees/Departments scenario: if I try to
    > fetch
    > all employees that are in exactly 2 departments I use a fetch
    > predicate
    > of "departments[SIZE] == 2" which works great everywhere except with
    > the
    > SQL store.  I learnt this the hard way.
    >
    > Thanks,
    >
    > --
previous month may 2008 next month
MTWTFSS
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31  
Go to today