mirror of
https://github.com/zhigang1992/RestKit.git
synced 2026-04-23 12:27:52 +08:00
Fix issue with incorrect quoting within the mapping cache causing duplicated objects. closes #598. refs #578
This commit is contained in:
@@ -26,14 +26,10 @@
|
||||
NSAssert(primaryKeyValue, @"Cannot find existing managed object by primary key without a value");
|
||||
NSAssert(managedObjectContext, @"Cannot find existing managed object with a context");
|
||||
|
||||
// NOTE: We coerce the primary key into a string (if possible) for convenience. Generally
|
||||
// primary keys are expressed either as a number or a string, so this lets us support either case interchangeably
|
||||
id lookupValue = [primaryKeyValue respondsToSelector:@selector(stringValue)] ? [primaryKeyValue stringValue] : primaryKeyValue;
|
||||
|
||||
NSFetchRequest* fetchRequest = [[NSFetchRequest alloc] init];
|
||||
[fetchRequest setEntity:entity];
|
||||
[fetchRequest setFetchLimit:1];
|
||||
[fetchRequest setPredicate:[NSPredicate predicateWithFormat:@"%@ = %@", mapping.primaryKeyAttribute, lookupValue]];
|
||||
[fetchRequest setPredicate:[NSPredicate predicateWithFormat:@"%K = %@", mapping.primaryKeyAttribute, primaryKeyValue]];
|
||||
NSArray *objects = [NSManagedObject executeFetchRequest:fetchRequest];
|
||||
RKLogDebug(@"Found objects '%@' using fetchRequest '%@'", objects, fetchRequest);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user