Skip to content

Commit 76634ec

Browse files
committed
Merge pull request #112 from rhodgkins/issue112
Relationships do not create the correct sub-entity
2 parents 1ba25c0 + 4239c91 commit 76634ec

File tree

30 files changed

+1316
-932
lines changed

30 files changed

+1316
-932
lines changed

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ language: objective-c
33
script:
44
- cd "exampleProjects/IncrementalStore"
55
# 32-bit tests
6-
- xctool -sdk iphonesimulator -scheme "Incremental Store Demo" test -destination "name=iPhone Retina (4-inch)"
6+
- xctool -sdk iphonesimulator -scheme "Incremental Store Demo" clean test -destination "name=iPhone Retina (4-inch)"
77
# 64-bit tests
8-
- xctool -sdk iphonesimulator -scheme "Incremental Store Demo" test -destination "name=iPhone Retina (4-inch 64-bit)"
8+
- xctool -sdk iphonesimulator -scheme "Incremental Store Demo" clean test -destination "name=iPhone Retina (4-inch 64-bit)"
99

Incremental Store/EncryptedStore.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ typedef NS_ENUM(NSInteger, EncryptedStoreError)
4242
- (id)valueForProperty:(NSPropertyDescription *)property
4343
inStatement:(sqlite3_stmt *)statement
4444
atIndex:(int)index;
45-
- (NSString *)foreignKeyColumnForRelationshipP:(NSRelationshipDescription *)relationship;
4645
- (NSString *)foreignKeyColumnForRelationship:(NSRelationshipDescription *)relationship;
4746
- (void)bindProperty:(NSPropertyDescription *)property
4847
withValue:(id)value

Incremental Store/EncryptedStore.m

Lines changed: 243 additions & 122 deletions
Large diffs are not rendered by default.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2+
<model userDefinedModelVersionIdentifier="" type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="5064" systemVersion="13E28" minimumToolsVersion="Xcode 4.3" macOSVersion="Automatic" iOSVersion="Automatic">
3+
<entity name="ChildA" representedClassName="ISDChildA" parentEntity="Parent" syncable="YES">
4+
<attribute name="attributeA" optional="YES" attributeType="String" syncable="YES"/>
5+
</entity>
6+
<entity name="ChildB" representedClassName="ISDChildB" parentEntity="Parent" syncable="YES">
7+
<attribute name="attributeB" optional="YES" attributeType="String" syncable="YES"/>
8+
</entity>
9+
<entity name="Parent" representedClassName="ISDParent" isAbstract="YES" syncable="YES">
10+
<attribute name="name" optional="YES" attributeType="String" syncable="YES"/>
11+
<relationship name="manyToManyInverse" optional="YES" toMany="YES" deletionRule="Cascade" destinationEntity="Root" inverseName="manyToMany" inverseEntity="Root" syncable="YES"/>
12+
<relationship name="oneToManyInverse" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="Root" inverseName="oneToMany" inverseEntity="Root" syncable="YES"/>
13+
<relationship name="oneToOneInverse" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="Root" inverseName="oneToOne" inverseEntity="Root" syncable="YES"/>
14+
</entity>
15+
<entity name="Root" representedClassName="ISDRoot" syncable="YES">
16+
<attribute name="name" optional="YES" attributeType="String" syncable="YES"/>
17+
<relationship name="manyToMany" optional="YES" toMany="YES" deletionRule="Cascade" destinationEntity="Parent" inverseName="manyToManyInverse" inverseEntity="Parent" syncable="YES"/>
18+
<relationship name="oneToMany" optional="YES" toMany="YES" deletionRule="Cascade" destinationEntity="Parent" inverseName="oneToManyInverse" inverseEntity="Parent" syncable="YES"/>
19+
<relationship name="oneToOne" optional="YES" maxCount="1" deletionRule="Cascade" destinationEntity="Parent" inverseName="oneToOneInverse" inverseEntity="Parent" syncable="YES"/>
20+
</entity>
21+
<elements>
22+
<element name="ChildA" positionX="-119" positionY="144" width="128" height="58"/>
23+
<element name="ChildB" positionX="79" positionY="144" width="128" height="58"/>
24+
<element name="Parent" positionX="-20" positionY="8" width="128" height="103"/>
25+
<element name="Root" positionX="-236" positionY="8" width="128" height="103"/>
26+
</elements>
27+
</model>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//
2+
// ISDChildA.h
3+
// Incremental Store
4+
//
5+
// Created by Richard Hodgkins on 31/08/2014.
6+
// Copyright (c) 2014 Caleb Davenport. All rights reserved.
7+
//
8+
9+
#import <Foundation/Foundation.h>
10+
#import <CoreData/CoreData.h>
11+
#import "ISDParent.h"
12+
13+
14+
@interface ISDChildA : ISDParent
15+
16+
@property (nonatomic, retain) NSString * attributeA;
17+
18+
@end
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//
2+
// ISDChildA.m
3+
// Incremental Store
4+
//
5+
// Created by Richard Hodgkins on 31/08/2014.
6+
// Copyright (c) 2014 Caleb Davenport. All rights reserved.
7+
//
8+
9+
#import "ISDChildA.h"
10+
11+
12+
@implementation ISDChildA
13+
14+
@dynamic attributeA;
15+
16+
@end
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//
2+
// ISDChildB.h
3+
// Incremental Store
4+
//
5+
// Created by Richard Hodgkins on 31/08/2014.
6+
// Copyright (c) 2014 Caleb Davenport. All rights reserved.
7+
//
8+
9+
#import <Foundation/Foundation.h>
10+
#import <CoreData/CoreData.h>
11+
#import "ISDParent.h"
12+
13+
14+
@interface ISDChildB : ISDParent
15+
16+
@property (nonatomic, retain) NSString * attributeB;
17+
18+
@end
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//
2+
// ISDChildB.m
3+
// Incremental Store
4+
//
5+
// Created by Richard Hodgkins on 31/08/2014.
6+
// Copyright (c) 2014 Caleb Davenport. All rights reserved.
7+
//
8+
9+
#import "ISDChildB.h"
10+
11+
12+
@implementation ISDChildB
13+
14+
@dynamic attributeB;
15+
16+
@end
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//
2+
// ISDModelCategories.h
3+
// Incremental Store
4+
//
5+
// Created by Richard Hodgkins on 31/08/2014.
6+
// Copyright (c) 2014 Caleb Davenport. All rights reserved.
7+
//
8+
9+
#import <CoreData/CoreData.h>
10+
11+
@interface NSManagedObject (ISDHelper)
12+
13+
+(NSString *)entityName;
14+
15+
+(instancetype)insertInManagedObjectContext:(NSManagedObjectContext *)context;
16+
17+
+(NSFetchRequest *)fetchRequest;
18+
19+
@end
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
//
2+
// ISDModelCategories.m
3+
// Incremental Store
4+
//
5+
// Created by Richard Hodgkins on 31/08/2014.
6+
// Copyright (c) 2014 Caleb Davenport. All rights reserved.
7+
//
8+
9+
#import "ISDModelCategories.h"
10+
11+
#import "ISDRoot.h"
12+
#import "ISDParent.h"
13+
#import "ISDChildA.h"
14+
#import "ISDChildB.h"
15+
16+
@implementation NSManagedObject (ISDHelper)
17+
18+
+(NSString *)entityName
19+
{
20+
@throw [NSException exceptionWithName:NSInternalInconsistencyException reason:@"Override in subclasses" userInfo:nil];
21+
}
22+
23+
+(instancetype)insertInManagedObjectContext:(NSManagedObjectContext *)context
24+
{
25+
return [NSEntityDescription insertNewObjectForEntityForName:[self entityName] inManagedObjectContext:context];
26+
}
27+
28+
+(NSFetchRequest *)fetchRequest
29+
{
30+
return [NSFetchRequest fetchRequestWithEntityName:[self entityName]];
31+
}
32+
33+
@end
34+
35+
@implementation ISDRoot (ISDHelper)
36+
37+
+(NSString *)entityName
38+
{
39+
return @"Root";
40+
}
41+
42+
@end
43+
44+
@implementation ISDChildA (ISDHelper)
45+
46+
+(NSString *)entityName
47+
{
48+
return @"ChildA";
49+
}
50+
51+
@end
52+
53+
@implementation ISDChildB (ISDHelper)
54+
55+
+(NSString *)entityName
56+
{
57+
return @"ChildB";
58+
}
59+
60+
@end

0 commit comments

Comments
 (0)