Core data: Inverse relationships with subclasses

2010-09-29 Thread Gideon King
Hi, I have a bidirectional one to one relationship between two entities like this: Foo - Bar, and Foo has a subclass FooSub. All entities are concrete. Sometimes when I set the inverse relationship it's like this aBar.toFoo = aFoo, and this works fine, but when it's linking back to the

Re: Core data: Inverse relationships with subclasses

2010-09-29 Thread jeremy
If your data store is SQLite, I believe the problem is the subclass FooSub. Since FooSub is a subclass of Foo, CoreData combines both Foo and FooSub into a single table whose columns include all properties from Foo AND FooSub. Consequently, when you create a new instance of Foo, columns from

Re: Core data: Inverse relationships with subclasses

2010-09-29 Thread Quincey Morris
On Sep 29, 2010, at 06:28, Gideon King wrote: I would have thought it would be OK for the relationship to point to an instance of FooSub shouldn't it? After all, it is a subclass of Foo. Or do things work differently for subclasses in Core Data? If so, how should I work around this

Re: Core data: Inverse relationships with subclasses

2010-09-29 Thread Jerry Krinock
On 2010 Sep 29, at 09:19, jeremy wrote: For a solution, rework your schema to subclass FooSub directly from NSManagedObject. That might work. If it doesn't, On Sep 29, 2010, at 9:28 AM, Gideon King wrote: All entities are concrete … I would have thought it would be OK for the

Re: Core data: Inverse relationships with subclasses

2010-09-29 Thread Gideon King
Thanks but no, it's an atomic store which gets written to XML. Regards Gideon On 30/09/2010, at 2:19 AM, jeremy wrote: If your data store is SQLite, I believe the problem is the subclass FooSub. Since FooSub is a subclass of Foo, CoreData combines both Foo and FooSub into a single table

Re: Core data: Inverse relationships with subclasses

2010-09-29 Thread Gideon King
Sorry, I should have been clearer. It is a sub-entity which is implemented as a subclass. Regards Gideon On 30/09/2010, at 3:39 AM, Quincey Morris wrote: On Sep 29, 2010, at 06:28, Gideon King wrote: I would have thought it would be OK for the relationship to point to an instance of

Re: Core data: Inverse relationships with subclasses

2010-09-29 Thread Gideon King
Hi Jerry, Can I just clarify what you mean about working around a bug on 10.5? I do need this to work on 10.5. FooSub is a subentity of Foo, and both have their classes defined, with FooSub's class being a subclass of Foo's class. Thanks Gideon On 30/09/2010, at 3:49 AM, Jerry Krinock

Re: Core data: Inverse relationships with subclasses

2010-09-29 Thread Quincey Morris
On Sep 29, 2010, at 15:30, Gideon King wrote: Sorry, I should have been clearer. It is a sub-entity which is implemented as a subclass. Hmm. I'd suspect a limitation of delete cascading rules, but that doesn't really fit with the error message your reported. Was that error text exactly what

Re: Core data: Inverse relationships with subclasses

2010-09-29 Thread Gideon King
That's actually how I eventually managed to work out that it appeared to be a subclass/subentity thing. It got picked up on validateForInsert when I was doing a Save As, and I checked the objects, and they all seemed fine. But this actually gives me an idea for a bit more testing that I can do

Re: Core data: Inverse relationships with subclasses

2010-09-29 Thread Jerry Krinock
On 2010 Sep 29, at 15:57, Gideon King wrote: Can I just clarify what you mean about working around a bug on 10.5? I do need this to work on 10.5. It was Quincey who tipped me off to this a few weeks ago:

Re: Core data: Inverse relationships with subclasses

2010-09-29 Thread Gideon King
Thanks Jerry, I'll need to keep that in mind. In the meantime, I've done more research this morning, and it appears that the underlying issue is that my one to one relationships that have an inverse are not being maintained properly during a Save As operation, even though at the managed