Re: Antw: Core Data PersistentStore woes with SQLite
Re: Antw: Core Data PersistentStore woes with SQLite
- Subject: Re: Antw: Core Data PersistentStore woes with SQLite
- From: Elise van Looij <email@hidden>
- Date: Wed, 15 Nov 2006 20:51:08 +0100
Op 15-nov-2006, om 15:23 heeft Jim Correia het volgende geschreven:
On Nov 15, 2006, at 7:36 AM, Elise van Looij wrote:
But is it really such a problem to fix? I may be missing some Core
Data architecture ramifications, but isn't this simply a case of
"on change attribute is NSSQLiteStore then ALTER TABLE" (excuse
the Applescript-accent)?
This issue has been hashed over before. Check the archives.
<http://www.cocoabuilder.com/archive/message/cocoa/
2005/5/11/135606> for example.
Bill says that SQLite's ALTER TABLE support was insufficient.
After all, I was able to work around the problem by manually
altering the table in the sqlite store.
If you are going to do that in a production environment, I'd triple
check your work against the a store generated by CoreData from the
new model. For certain properties, there may be indices and/or
additional tables involved.
And Core Data is able to do the same thing by itself when using an
xml store.
There isn't any migration going on here. An XML store is an atomic
store, which means it is written in its entirety for each save. An
SQLite store is created and then updated, so the initial structure
dictates what can go into it. The only reason you are getting away
with this in the XML store is that NULL is an acceptable value for
the new attribute.
Dropping an attribute or adding an attribute where NULL (or the
model's default value) is an appropriate value is the simplest case
for data migration. After that, things get trickier.
Right, I see your point. It is nice to finally have things spelled
out. I have googled myself silly for the past weeks looking for any
scraps of information on Core Data and nowhere does it say: "Warning!
Before you change your persistent store from NSXMLStoreType to
NSSQLiteStoreType, be advised that you won't be able to make a single
change to your data model because if you do you'll get a NSRunloop
"no such column" error and your application won't work anymore."
Apple's Core Data Programming Guide has sections on "Store Types and
Behaviors" and "Store-specific behavior" and "Saving to a SQLite
Store" but that little tidbit of information doesn't get mentioned.
Similarly, Cocoa Dev Central offers a great tutorial on how to Build
a Core Data Application in which it shows you how to change your
store, but no word on the potentially catastrophic consequences. Am I
angry? Yes, I am.
Elise van Looij
_______________________________________________
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