Re: NSPredicate with CoreData SQL store behavior
Re: NSPredicate with CoreData SQL store behavior
- Subject: Re: NSPredicate with CoreData SQL store behavior
- From: Aurélien Hugelé <email@hidden>
- Date: Wed, 15 Mar 2006 18:14:40 +0100
On 15 mars 06, at 16:12, Jesse Grosjean wrote:
I have a few questions concerning NSPredicate and a CoreData SQL
store. I'm trying to get my assumptions strait, I though I knew
this stuff, but recently I've run into a couple of problems that I
didn't expect.
First at some point I "learned" that when fetching on a SQL type
store predicates would only return results from the entities that
were committed to the store. For example if I add a new entity it
would not show up in the fetch results until I saved the store. In
my head this makes sense since the predicate is implemented as an
SQL query. And this is also the behavior that I see in my
application that constructs its own core data stack.
But, I was just doing some tests with default NSPersitentDocument
based application and the above rule doesn't seem to hold. I create
a new document, saved as SQL type. Closed and then reopened the
document (to make sure that it was using the SQL store and not the
initial in memory store) and then I added a new entity and that
entity showed up in my fetches immediately without me needing to
save the document. Also if I made a modification to an existing
attribute that change would be reflected in the search results
without me needing to save.
Does anyone know why this would be? Is the NSPersitentDocument
class doing something special to allow fetches to see changes
before they are committed to the store, or was my original
assumption wrong? I would love to get this behavior into my own
managed object stack that doesn't use NSPersitentDocument.
I'm pretty sure that a fetch should return ALL objects matching the
predicate, saved or not. I think it was explained at WWDC. IIRC they
even said that non saved objects are returned in the fetch result,
but that this slow down the fetch a bit. They said that saved objects
are faster to obtain...
I'm pretty sure that there is no difference between an
NSPersistentDocument and a normal CD stack...
I suppose there is a bug in your code... but it may even be in
Apple's code. AFAIK, i never encounter this problem!
My second question is what is the best way to do a "contains"
search on strings in the SQL store? I had been using seaches like
"myStringAttribute like[cd] '*searchstring*'", but I just found out
that that type of search seems to completely break (no results) if
myStringAttribute contains any newLine characters (return key). Is
that expected behavior? And if so what is the best way to find if a
string attribute (that might have new lines) contains another string?
"CONTAINS[cd]" ?
Thanks for any pointers, my brains feeling a bit frazzled at the
moment.
Jesse
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40gumitech.com
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden