-
Notifications
You must be signed in to change notification settings - Fork 194
Dictionaries nested more than 1 level deep break findOrCreate: #60
Comments
Fixed via #87, thanks! |
This still seems to be an issue on 1.5 using models without primary keys. Is that expected behavior? I receive: |
Can you provide an example of the code that's calling |
My graph: Network has many Rooms, Room has many Devices.
My Room mappings:
My Network mappings:
|
It seems to be the |
Were you able to fix this @Tylerc230 ? |
…of deepness. Fixes supermarin#60 with error message 'to-many key not allowed here'
We manage to fix this, with:
This will preserve one-to-many relationships fetching without crashing when deeper level. |
@dzenbot hey Ignacio, sorry I was on a long vacation. will take a look on this today |
I still have the // Car+Mappings.m
@implementation Car (Mappings)
+ (NSDictionary *)mappings {
return @{
@"seats": @{@"class": [Seat class]},
@"owner": @{@"class": [Person class]
},
};
}
@end
// Seat+Mappings.m
@implementation Seat (Mappings)
+ (NSDictionary *)mappings {
return @{
@"car": @{@"class": [Car class]},
};
}
@end
// using the below JSON data
NSDictionary *JSON = @{
@"first_name": @"Marin",
@"last_name": @"Usalj",
@"age": @25,
@"is_member": @"true",
@"cars": @[
@{ @"hp": @220, @"make": @"Trabant",
@"seats": @[
@{@"orderId": @1},
@{@"orderId": @2},
]},
],
};
Person *person = [Person create:JSON]; Am I something wrong here |
For those who are faced with this problem. Find a different framework. This crude. |
This code helped me. |
Right now OR handles creating nested entity objects during
update:
using the classes specified in an entity'smappings
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, anOwner
class, and aCar
class, where aRestaurant
has anOwner
and anOwner
has aCar
When I want to update my
Restaurant
instance with a dictionary that looks like so:Then I should have one
Restaurant
, oneOwner
, and oneCar
when the update is complete.The text was updated successfully, but these errors were encountered: