Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug in the code #1858

Closed
Beniamiiin opened this issue Apr 3, 2014 · 5 comments
Closed

Bug in the code #1858

Beniamiiin opened this issue Apr 3, 2014 · 5 comments

Comments

@Beniamiiin
Copy link

This method for file RKMappingOperation.m have bugs.

- (BOOL)mapNestedObject:(id)anObject toObject:(id)anotherObject withRelationshipMapping:(RKRelationshipMapping *)relationshipMapping metadata:(NSDictionary *)metadata
{
    NSAssert(anObject, @"Cannot map nested object without a nested source object");
    NSAssert(anotherObject, @"Cannot map nested object without a destination object");
    NSAssert(relationshipMapping, @"Cannot map a nested object relationship without a relationship mapping");
    NSError *error = nil;

    RKLogTrace(@"Performing nested object mapping using mapping %@ for data: %@", relationshipMapping, anObject);
    NSDictionary *subOperationMetadata = RKDictionaryByMergingDictionaryWithDictionary(self.metadata, metadata);
    RKMappingOperation *subOperation = [[RKMappingOperation alloc] initWithSourceObject:anObject destinationObject:anotherObject mapping:relationshipMapping.mapping];
    subOperation.dataSource = self.dataSource;
    subOperation.delegate = self.delegate;
    subOperation.metadata = subOperationMetadata;
    subOperation.parentSourceObject = [self parentObjectForRelationshipMapping:relationshipMapping];
    subOperation.rootSourceObject = self.rootSourceObject;
    [subOperation start];

    if (subOperation.error) {
        RKLogWarning(@"WARNING: Failed mapping nested object: %@", [error localizedDescription]);
    } else {
        [self.mappingInfo addPropertyMapping:relationshipMapping];
        [self.mappingInfo addMappingInfo:subOperation.mappingInfo forRelationshipMapping:relationshipMapping];
    }

    return YES;
}

On 14 line checks to subOperation for error

if (subOperation.error) {

and if there is an error, the error log output.

if (subOperation.error) {
     RKLogWarning(@"WARNING: Failed mapping nested object: %@", [error localizedDescription]);
}

But as you can see the logs displayed

RKLogWarning(@"WARNING: Failed mapping nested object: %@", [error localizedDescription]);

in place

RKLogWarning(@"WARNING: Failed mapping nested object: %@", [subOperation.error localizedDescription]);
@segiddins
Copy link
Member

@BenjaminSarkisyan would appreciate a pull request to fix this

@Beniamiiin
Copy link
Author

Okay, but what branch do pull request?

@segiddins
Copy link
Member

Development

-Samuel E. Giddins

On Apr 3, 2014, at 11:16 PM, Beniamin notifications@github.com wrote:

Okay, but what branch do pull request?


Reply to this email directly or view it on GitHub.

@airdrummingfool
Copy link

There is an existing PR for this at #1752.

@blakewatters
Copy link
Member

Closing. Merged #1752

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants