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
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
//
2+
// ISDParent.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+
12+
@class ISDRoot;
13+
14+
@interface ISDParent : NSManagedObject
15+
16+
@property (nonatomic, retain) NSString * name;
17+
@property (nonatomic, retain) ISDRoot *oneToManyInverse;
18+
@property (nonatomic, retain) ISDRoot *oneToOneInverse;
19+
@property (nonatomic, retain) NSSet *manyToManyInverse;
20+
@end
21+
22+
@interface ISDParent (CoreDataGeneratedAccessors)
23+
24+
- (void)addManyToManyInverseObject:(ISDRoot *)value;
25+
- (void)removeManyToManyInverseObject:(ISDRoot *)value;
26+
- (void)addManyToManyInverse:(NSSet *)values;
27+
- (void)removeManyToManyInverse:(NSSet *)values;
28+
29+
@end
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//
2+
// ISDParent.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 "ISDParent.h"
10+
#import "ISDRoot.h"
11+
12+
13+
@implementation ISDParent
14+
15+
@dynamic name;
16+
@dynamic oneToManyInverse;
17+
@dynamic oneToOneInverse;
18+
@dynamic manyToManyInverse;
19+
20+
@end
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
//
2+
// ISDRoot.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+
12+
@class ISDParent;
13+
14+
@interface ISDRoot : NSManagedObject
15+
16+
@property (nonatomic, retain) NSString * name;
17+
@property (nonatomic, retain) NSSet *oneToMany;
18+
@property (nonatomic, retain) ISDParent *oneToOne;
19+
@property (nonatomic, retain) NSSet *manyToMany;
20+
@end
21+
22+
@interface ISDRoot (CoreDataGeneratedAccessors)
23+
24+
- (void)addOneToManyObject:(ISDParent *)value;
25+
- (void)removeOneToManyObject:(ISDParent *)value;
26+
- (void)addOneToMany:(NSSet *)values;
27+
- (void)removeOneToMany:(NSSet *)values;
28+
29+
- (void)addManyToManyObject:(ISDParent *)value;
30+
- (void)removeManyToManyObject:(ISDParent *)value;
31+
- (void)addManyToMany:(NSSet *)values;
32+
- (void)removeManyToMany:(NSSet *)values;
33+
34+
@end
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//
2+
// ISDRoot.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 "ISDRoot.h"
10+
#import "ISDParent.h"
11+
12+
13+
@implementation ISDRoot
14+
15+
@dynamic name;
16+
@dynamic oneToMany;
17+
@dynamic oneToOne;
18+
@dynamic manyToMany;
19+
20+
@end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"images" : [
3+
{
4+
"idiom" : "iphone",
5+
"scale" : "1x",
6+
"size" : "57x57"
7+
},
8+
{
9+
"idiom" : "iphone",
10+
"scale" : "2x",
11+
"size" : "57x57"
12+
},
13+
{
14+
"idiom" : "iphone",
15+
"scale" : "2x",
16+
"size" : "60x60"
17+
},
18+
{
19+
"idiom" : "iphone",
20+
"scale" : "1x",
21+
"size" : "29x29"
22+
},
23+
{
24+
"idiom" : "iphone",
25+
"scale" : "2x",
26+
"size" : "29x29"
27+
},
28+
{
29+
"idiom" : "iphone",
30+
"scale" : "2x",
31+
"size" : "40x40"
32+
}
33+
],
34+
"info" : {
35+
"version" : 1,
36+
"author" : "xcode"
37+
}
38+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"images" : [
3+
{
4+
"orientation" : "portrait",
5+
"idiom" : "iphone",
6+
"minimum-system-version" : "7.0",
7+
"subtype" : "retina4",
8+
"scale" : "2x"
9+
},
10+
{
11+
"idiom" : "iphone",
12+
"scale" : "1x",
13+
"orientation" : "portrait"
14+
},
15+
{
16+
"idiom" : "iphone",
17+
"scale" : "2x",
18+
"orientation" : "portrait"
19+
},
20+
{
21+
"orientation" : "portrait",
22+
"idiom" : "iphone",
23+
"subtype" : "retina4",
24+
"scale" : "2x"
25+
},
26+
{
27+
"orientation" : "portrait",
28+
"idiom" : "iphone",
29+
"minimum-system-version" : "7.0",
30+
"scale" : "2x"
31+
}
32+
],
33+
"info" : {
34+
"version" : 1,
35+
"author" : "xcode"
36+
}
37+
}

exampleProjects/IncrementalStore/Incremental Store Demo/Incremental Store Demo-Info.plist

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
<string>${PRODUCT_NAME}</string>
99
<key>CFBundleExecutable</key>
1010
<string>${EXECUTABLE_NAME}</string>
11+
<key>CFBundleIcons</key>
12+
<dict/>
13+
<key>CFBundleIcons~ipad</key>
14+
<dict/>
1115
<key>CFBundleIdentifier</key>
1216
<string>org.mitre.${PRODUCT_NAME:rfc1034identifier}</string>
1317
<key>CFBundleInfoDictionaryVersion</key>

0 commit comments

Comments
 (0)