Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Verify that a mapping relationship performed on a parent source object h... #1115

Closed
wants to merge 1 commit into from

2 participants

@cfis

...as at least one key path with a value. Potential fix for #1114.

Charlie Savage Verify that a mapping relationship performed on a parent source objec…
…t has at least one key path with a value. Potential fix for #1114.
d15d779
@s2m-updater s2m-updater referenced this pull request from a commit in SinnerSchraderMobileMirrors/RestKit
@blakewatters blakewatters Add support for skipping an aggregate relationship mapping in the eve…
…nt that the parent representation does not contain any values for the property mappings of the concrete `RKObjectMapping` configured for the relationship. fixes #1114, closes #1115
a03191c
@stojanovicigi stojanovicigi referenced this pull request from a commit in CenterDevice/RestKit
@blakewatters blakewatters Add support for skipping an aggregate relationship mapping in the eve…
…nt that the parent representation does not contain any values for the property mappings of the concrete `RKObjectMapping` configured for the relationship. fixes #1114, closes #1115
d52a3c4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 29, 2012
  1. Verify that a mapping relationship performed on a parent source objec…

    Charlie Savage authored
    …t has at least one key path with a value. Potential fix for #1114.
This page is out of date. Refresh to see the latest.
Showing with 25 additions and 2 deletions.
  1. +25 −2 Code/ObjectMapping/RKMappingOperation.m
View
27 Code/ObjectMapping/RKMappingOperation.m
@@ -584,9 +584,32 @@ - (BOOL)applyRelationshipMappings
for (RKRelationshipMapping *relationshipMapping in [self relationshipMappings]) {
if ([self isCancelled]) return NO;
+ id value = nil;
+
// The nil source keyPath indicates that we want to map directly from the parent representation
- id value = (relationshipMapping.sourceKeyPath == nil) ? self.sourceObject : [self.sourceObject valueForKeyPath:relationshipMapping.sourceKeyPath];
-
+ if (relationshipMapping.sourceKeyPath )
+ {
+ value = [self.sourceObject valueForKeyPath:relationshipMapping.sourceKeyPath];
+ }
+ else
+ {
+ value = self.sourceObject;
+
+ BOOL foundKeyPath = NO;
+ // Make sure at least one attribute has a value (should we check is present instead?)
+ RKObjectMapping *mapping = (RKObjectMapping*)(relationshipMapping.mapping);
+ for (RKPropertyMapping *propertyMapping in mapping.propertyMappings)
+ {
+ if ([self.sourceObject valueForKeyPath:propertyMapping.sourceKeyPath])
+ {
+ foundKeyPath = YES;
+ break;
+ }
+ }
+ if (!foundKeyPath)
+ continue;
+ }
+
// Track that we applied this mapping
[mappingsApplied addObject:relationshipMapping];
Something went wrong with that request. Please try again.