You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Sep 12, 2018. It is now read-only.
Repository navigation
This repository was archived by the owner on Sep 12, 2018. It is now read-only.
Dictionaries nested more than 1 level deep break findOrCreate: #60
Right now OR handles creating nested entity objects during update: using the classes specified in an entity's mappings block. However, when a dictionary contains multiple levels of objects, the nested dictionaries aren't processed recursively, and are treated like values for entity property keys, so -[NSManagedObject predicateForDictionary:] returns a format like: id == 4 AND type == Cajun AND owner == { id = 6 }, resulting in a crash, since the owner value is not in a valid format.
Example
Given I have a Restaurant class, an Owner class, and a Car class, where a Restaurant has an Owner and an Owner has a Car
It seems to be the findOrCreate: call calling where: that things go south. It attempts to do a property by property query and when it reaches the devices property it breaks since (I don't believe) you can compare to many relationships in a Predicate.
Activity
stephencelis commentedon Mar 27, 2014
Fixed via #87, thanks!
Tylerc230 commentedon Apr 24, 2014
This still seems to be an issue on 1.5 using models without primary keys. Is that expected behavior? I receive:
2014-04-24 14:34:53.669 ZuliApp[17833:60b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'to-many key not allowed here'
*** First throw call stack:
(
0 CoreFoundation 0x032e11e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x0303d8e5 objc_exception_throw + 44
2 CoreData 0x0117062c -[NSSQLGenerator newSQLStatementForFetchRequest:ignoreInheritance:countOnly:nestingLevel:] + 1308
3 CoreData 0x0116ffb8 -[NSSQLAdapter _newSelectStatementWithFetchRequest:ignoreInheritance:] + 472
4 CoreData 0x0116fdd0 -[NSSQLAdapter newSelectStatementWithFetchRequest:] + 48
5 CoreData 0x0116fb91 -[NSSQLCore newRowsForFetchPlan:] + 129
6 CoreData 0x0116f31d -[NSSQLCore objectsForFetchRequest:inContext:] + 701
7 CoreData 0x0116edcf -[NSSQLCore executeRequest:withContext:error:] + 383
8 CoreData 0x0116e7f2 -[NSPersistentStoreCoordinator executeRequest:withContext:error:] + 4466
9 CoreData 0x0116bf56 -[NSManagedObjectContext executeFetchRequest:error:] + 566
10 ZuliApp 0x0023a368 +[NSManagedObject(ActiveRecord) fetchWithCondition:inContext:withOrder:fetchLimit:] + 520
11 ZuliApp 0x00237ad4 +[NSManagedObject(ActiveRecord) where:inContext:order:limit:] + 212
12 ZuliApp 0x00237744 +[NSManagedObject(ActiveRecord) where:inContext:] + 148
13 ZuliApp 0x00236e22 +[NSManagedObject(ActiveRecord) findOrCreate:inContext:] + 194
14 ZuliApp 0x0023b554 +[NSManagedObject(Mappings) objectOrSetOfObjectsFromValue:ofClass:inContext:] + 292
15 ZuliApp 0x0023b87a __77+[NSManagedObject(Mappings) objectOrSetOfObjectsFromValue:ofClass:inContext:]_block_invoke + 106
16 ZuliApp 0x0023d1db -[NSArray(ObjectiveSugar) map:] + 443
17 ZuliApp 0x0023b643 +[NSManagedObject(Mappings) objectOrSetOfObjectsFromValue:ofClass:inContext:] + 531
18 ZuliApp 0x0023b393 +[NSManagedObject(Mappings) transformValue:forRemoteKey:inContext:] + 323
19 ZuliApp 0x00239071 +[NSManagedObject(ActiveRecord) transformProperties:withContext:] + 1089
20 ZuliApp 0x00238346 -[NSManagedObject(ActiveRecord) update:] + 246
21 ZuliApp 0x00238102 +[NSManagedObject(ActiveRecord) create:inContext:] + 210
22 Zuli
stephencelis commentedon Apr 24, 2014
Can you provide an example of the code that's calling
update:?Tylerc230 commentedon Apr 24, 2014
My graph: Network has many Rooms, Room has many Devices.
My Room mappings:
My Network mappings:
Tylerc230 commentedon Apr 24, 2014
It seems to be the
findOrCreate:call callingwhere:that things go south. It attempts to do a property by property query and when it reaches thedevicesproperty it breaks since (I don't believe) you can compare to many relationships in a Predicate.dzenbot commentedon Aug 5, 2014
Were you able to fix this @Tylerc230 ?
I tried several things, with no success...
Fixes crash when fetching one-to-many relationship with higher level …
dzenbot commentedon Aug 6, 2014
We manage to fix this, with:
This will preserve one-to-many relationships fetching without crashing when deeper level.
supermarin commentedon Aug 19, 2014
@dzenbot hey Ignacio, sorry I was on a long vacation. will take a look on this today
donly commentedon Aug 15, 2015
I still have the
'to-many key not allowed here'error thereAm I something wrong here
Alexandeer commentedon Apr 19, 2016
For those who are faced with this problem. Find a different framework. This crude.
Alexandeer commentedon Apr 20, 2016
This code helped me.