Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Store new objects by lookupValue instead of primaryKeyValue. This avo…

…ids creation of duplicated objects the are manufactured by findOrCreateInstanceOfEntity:
  • Loading branch information...
commit 40eb842dcce0dba0d76063eb9147c89033049f67 1 parent e31061b
@blakewatters blakewatters authored
View
2  Code/CoreData/RKManagedObjectStore.m
@@ -349,7 +349,7 @@ - (NSManagedObject*)findOrCreateInstanceOfEntity:(NSEntityDescription*)entity wi
if (object == nil) {
object = [[[NSManagedObject alloc] initWithEntity:entity insertIntoManagedObjectContext:self.managedObjectContext] autorelease];
- [dictionary setObject:object forKey:primaryKeyValue];
+ [dictionary setObject:object forKey:lookupValue];
}
return object;
View
10 RestKit.xcodeproj/xcshareddata/xcschemes/UISpec.xcscheme
@@ -62,7 +62,7 @@
<EnvironmentVariables>
<EnvironmentVariable
key = "UISPEC_SPEC"
- value = "RKManagedObjectLoaderSpec"
+ value = "RKObjectMappingNextGenSpec"
isEnabled = "NO">
</EnvironmentVariable>
<EnvironmentVariable
@@ -72,7 +72,7 @@
</EnvironmentVariable>
<EnvironmentVariable
key = "UISPEC_EXAMPLE"
- value = "itShouldDeleteObjectFromLocalStoreOnDELETE"
+ value = "itShouldRegisterRailsIdiomaticObjects"
isEnabled = "NO">
</EnvironmentVariable>
<EnvironmentVariable
@@ -87,12 +87,12 @@
</EnvironmentVariable>
<EnvironmentVariable
key = "UISPEC_SPEC"
- value = "RKObjectMappingNextGenSpec"
- isEnabled = "NO">
+ value = "RKManagedObjectStoreSpec"
+ isEnabled = "YES">
</EnvironmentVariable>
<EnvironmentVariable
key = "UISPEC_EXAMPLE"
- value = "itShouldSetTheErrorWhenMappingOperationFails"
+ value = "itShouldAllowYouToPOSTAnObjectAndMapBackNonNestedContent"
isEnabled = "NO">
</EnvironmentVariable>
<EnvironmentVariable
View
7 Specs/CoreData/RKManagedObjectStoreSpec.m
@@ -24,4 +24,11 @@ - (void)itShouldCoercePrimaryKeysToStringsForLookup {
assertThat(newReference, is(equalTo(human)));
}
+- (void)itShouldStoreNewInstancesOfCreatedObjectsByStringKey {
+ RKManagedObjectStore* objectStore = RKSpecNewManagedObjectStore();
+ NSManagedObject* firstInstance = [objectStore findOrCreateInstanceOfEntity:[RKHuman entity] withPrimaryKeyAttribute:@"railsID" andValue:[NSNumber numberWithInt:1234]];
+ NSManagedObject* secondInstance = [objectStore findOrCreateInstanceOfEntity:[RKHuman entity] withPrimaryKeyAttribute:@"railsID" andValue:[NSNumber numberWithInt:1234]];
+ assertThat(secondInstance, is(equalTo(firstInstance)));
+}
+
@end
Please sign in to comment.
Something went wrong with that request. Please try again.