Skip to content

Commit

Permalink
Merge pull request #112 from rhodgkins/issue112
Browse files Browse the repository at this point in the history
Relationships do not create the correct sub-entity
  • Loading branch information
gavin-black committed Sep 8, 2014
2 parents 1ba25c0 + 4239c91 commit 76634ec
Show file tree
Hide file tree
Showing 30 changed files with 1,316 additions and 932 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ language: objective-c
script:
- cd "exampleProjects/IncrementalStore"
# 32-bit tests
- xctool -sdk iphonesimulator -scheme "Incremental Store Demo" test -destination "name=iPhone Retina (4-inch)"
- xctool -sdk iphonesimulator -scheme "Incremental Store Demo" clean test -destination "name=iPhone Retina (4-inch)"
# 64-bit tests
- xctool -sdk iphonesimulator -scheme "Incremental Store Demo" test -destination "name=iPhone Retina (4-inch 64-bit)"
- xctool -sdk iphonesimulator -scheme "Incremental Store Demo" clean test -destination "name=iPhone Retina (4-inch 64-bit)"

1 change: 0 additions & 1 deletion Incremental Store/EncryptedStore.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ typedef NS_ENUM(NSInteger, EncryptedStoreError)
- (id)valueForProperty:(NSPropertyDescription *)property
inStatement:(sqlite3_stmt *)statement
atIndex:(int)index;
- (NSString *)foreignKeyColumnForRelationshipP:(NSRelationshipDescription *)relationship;
- (NSString *)foreignKeyColumnForRelationship:(NSRelationshipDescription *)relationship;
- (void)bindProperty:(NSPropertyDescription *)property
withValue:(id)value
Expand Down
365 changes: 243 additions & 122 deletions Incremental Store/EncryptedStore.m

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<model userDefinedModelVersionIdentifier="" type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="5064" systemVersion="13E28" minimumToolsVersion="Xcode 4.3" macOSVersion="Automatic" iOSVersion="Automatic">
<entity name="ChildA" representedClassName="ISDChildA" parentEntity="Parent" syncable="YES">
<attribute name="attributeA" optional="YES" attributeType="String" syncable="YES"/>
</entity>
<entity name="ChildB" representedClassName="ISDChildB" parentEntity="Parent" syncable="YES">
<attribute name="attributeB" optional="YES" attributeType="String" syncable="YES"/>
</entity>
<entity name="Parent" representedClassName="ISDParent" isAbstract="YES" syncable="YES">
<attribute name="name" optional="YES" attributeType="String" syncable="YES"/>
<relationship name="manyToManyInverse" optional="YES" toMany="YES" deletionRule="Cascade" destinationEntity="Root" inverseName="manyToMany" inverseEntity="Root" syncable="YES"/>
<relationship name="oneToManyInverse" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="Root" inverseName="oneToMany" inverseEntity="Root" syncable="YES"/>
<relationship name="oneToOneInverse" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="Root" inverseName="oneToOne" inverseEntity="Root" syncable="YES"/>
</entity>
<entity name="Root" representedClassName="ISDRoot" syncable="YES">
<attribute name="name" optional="YES" attributeType="String" syncable="YES"/>
<relationship name="manyToMany" optional="YES" toMany="YES" deletionRule="Cascade" destinationEntity="Parent" inverseName="manyToManyInverse" inverseEntity="Parent" syncable="YES"/>
<relationship name="oneToMany" optional="YES" toMany="YES" deletionRule="Cascade" destinationEntity="Parent" inverseName="oneToManyInverse" inverseEntity="Parent" syncable="YES"/>
<relationship name="oneToOne" optional="YES" maxCount="1" deletionRule="Cascade" destinationEntity="Parent" inverseName="oneToOneInverse" inverseEntity="Parent" syncable="YES"/>
</entity>
<elements>
<element name="ChildA" positionX="-119" positionY="144" width="128" height="58"/>
<element name="ChildB" positionX="79" positionY="144" width="128" height="58"/>
<element name="Parent" positionX="-20" positionY="8" width="128" height="103"/>
<element name="Root" positionX="-236" positionY="8" width="128" height="103"/>
</elements>
</model>
18 changes: 18 additions & 0 deletions exampleProjects/IncrementalStore/ClassModels/ISDChildA.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//
// ISDChildA.h
// Incremental Store
//
// Created by Richard Hodgkins on 31/08/2014.
// Copyright (c) 2014 Caleb Davenport. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <CoreData/CoreData.h>
#import "ISDParent.h"


@interface ISDChildA : ISDParent

@property (nonatomic, retain) NSString * attributeA;

@end
16 changes: 16 additions & 0 deletions exampleProjects/IncrementalStore/ClassModels/ISDChildA.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//
// ISDChildA.m
// Incremental Store
//
// Created by Richard Hodgkins on 31/08/2014.
// Copyright (c) 2014 Caleb Davenport. All rights reserved.
//

#import "ISDChildA.h"


@implementation ISDChildA

@dynamic attributeA;

@end
18 changes: 18 additions & 0 deletions exampleProjects/IncrementalStore/ClassModels/ISDChildB.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//
// ISDChildB.h
// Incremental Store
//
// Created by Richard Hodgkins on 31/08/2014.
// Copyright (c) 2014 Caleb Davenport. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <CoreData/CoreData.h>
#import "ISDParent.h"


@interface ISDChildB : ISDParent

@property (nonatomic, retain) NSString * attributeB;

@end
16 changes: 16 additions & 0 deletions exampleProjects/IncrementalStore/ClassModels/ISDChildB.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//
// ISDChildB.m
// Incremental Store
//
// Created by Richard Hodgkins on 31/08/2014.
// Copyright (c) 2014 Caleb Davenport. All rights reserved.
//

#import "ISDChildB.h"


@implementation ISDChildB

@dynamic attributeB;

@end
19 changes: 19 additions & 0 deletions exampleProjects/IncrementalStore/ClassModels/ISDModelCategories.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//
// ISDModelCategories.h
// Incremental Store
//
// Created by Richard Hodgkins on 31/08/2014.
// Copyright (c) 2014 Caleb Davenport. All rights reserved.
//

#import <CoreData/CoreData.h>

@interface NSManagedObject (ISDHelper)

+(NSString *)entityName;

+(instancetype)insertInManagedObjectContext:(NSManagedObjectContext *)context;

+(NSFetchRequest *)fetchRequest;

@end
60 changes: 60 additions & 0 deletions exampleProjects/IncrementalStore/ClassModels/ISDModelCategories.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
//
// ISDModelCategories.m
// Incremental Store
//
// Created by Richard Hodgkins on 31/08/2014.
// Copyright (c) 2014 Caleb Davenport. All rights reserved.
//

#import "ISDModelCategories.h"

#import "ISDRoot.h"
#import "ISDParent.h"
#import "ISDChildA.h"
#import "ISDChildB.h"

@implementation NSManagedObject (ISDHelper)

+(NSString *)entityName
{
@throw [NSException exceptionWithName:NSInternalInconsistencyException reason:@"Override in subclasses" userInfo:nil];
}

+(instancetype)insertInManagedObjectContext:(NSManagedObjectContext *)context
{
return [NSEntityDescription insertNewObjectForEntityForName:[self entityName] inManagedObjectContext:context];
}

+(NSFetchRequest *)fetchRequest
{
return [NSFetchRequest fetchRequestWithEntityName:[self entityName]];
}

@end

@implementation ISDRoot (ISDHelper)

+(NSString *)entityName
{
return @"Root";
}

@end

@implementation ISDChildA (ISDHelper)

+(NSString *)entityName
{
return @"ChildA";
}

@end

@implementation ISDChildB (ISDHelper)

+(NSString *)entityName
{
return @"ChildB";
}

@end
29 changes: 29 additions & 0 deletions exampleProjects/IncrementalStore/ClassModels/ISDParent.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//
// ISDParent.h
// Incremental Store
//
// Created by Richard Hodgkins on 31/08/2014.
// Copyright (c) 2014 Caleb Davenport. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <CoreData/CoreData.h>

@class ISDRoot;

@interface ISDParent : NSManagedObject

@property (nonatomic, retain) NSString * name;
@property (nonatomic, retain) ISDRoot *oneToManyInverse;
@property (nonatomic, retain) ISDRoot *oneToOneInverse;
@property (nonatomic, retain) NSSet *manyToManyInverse;
@end

@interface ISDParent (CoreDataGeneratedAccessors)

- (void)addManyToManyInverseObject:(ISDRoot *)value;
- (void)removeManyToManyInverseObject:(ISDRoot *)value;
- (void)addManyToManyInverse:(NSSet *)values;
- (void)removeManyToManyInverse:(NSSet *)values;

@end
20 changes: 20 additions & 0 deletions exampleProjects/IncrementalStore/ClassModels/ISDParent.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//
// ISDParent.m
// Incremental Store
//
// Created by Richard Hodgkins on 31/08/2014.
// Copyright (c) 2014 Caleb Davenport. All rights reserved.
//

#import "ISDParent.h"
#import "ISDRoot.h"


@implementation ISDParent

@dynamic name;
@dynamic oneToManyInverse;
@dynamic oneToOneInverse;
@dynamic manyToManyInverse;

@end
34 changes: 34 additions & 0 deletions exampleProjects/IncrementalStore/ClassModels/ISDRoot.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
//
// ISDRoot.h
// Incremental Store
//
// Created by Richard Hodgkins on 31/08/2014.
// Copyright (c) 2014 Caleb Davenport. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <CoreData/CoreData.h>

@class ISDParent;

@interface ISDRoot : NSManagedObject

@property (nonatomic, retain) NSString * name;
@property (nonatomic, retain) NSSet *oneToMany;
@property (nonatomic, retain) ISDParent *oneToOne;
@property (nonatomic, retain) NSSet *manyToMany;
@end

@interface ISDRoot (CoreDataGeneratedAccessors)

- (void)addOneToManyObject:(ISDParent *)value;
- (void)removeOneToManyObject:(ISDParent *)value;
- (void)addOneToMany:(NSSet *)values;
- (void)removeOneToMany:(NSSet *)values;

- (void)addManyToManyObject:(ISDParent *)value;
- (void)removeManyToManyObject:(ISDParent *)value;
- (void)addManyToMany:(NSSet *)values;
- (void)removeManyToMany:(NSSet *)values;

@end
20 changes: 20 additions & 0 deletions exampleProjects/IncrementalStore/ClassModels/ISDRoot.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//
// ISDRoot.m
// Incremental Store
//
// Created by Richard Hodgkins on 31/08/2014.
// Copyright (c) 2014 Caleb Davenport. All rights reserved.
//

#import "ISDRoot.h"
#import "ISDParent.h"


@implementation ISDRoot

@dynamic name;
@dynamic oneToMany;
@dynamic oneToOne;
@dynamic manyToMany;

@end
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"images" : [
{
"idiom" : "iphone",
"scale" : "1x",
"size" : "57x57"
},
{
"idiom" : "iphone",
"scale" : "2x",
"size" : "57x57"
},
{
"idiom" : "iphone",
"scale" : "2x",
"size" : "60x60"
},
{
"idiom" : "iphone",
"scale" : "1x",
"size" : "29x29"
},
{
"idiom" : "iphone",
"scale" : "2x",
"size" : "29x29"
},
{
"idiom" : "iphone",
"scale" : "2x",
"size" : "40x40"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"images" : [
{
"orientation" : "portrait",
"idiom" : "iphone",
"minimum-system-version" : "7.0",
"subtype" : "retina4",
"scale" : "2x"
},
{
"idiom" : "iphone",
"scale" : "1x",
"orientation" : "portrait"
},
{
"idiom" : "iphone",
"scale" : "2x",
"orientation" : "portrait"
},
{
"orientation" : "portrait",
"idiom" : "iphone",
"subtype" : "retina4",
"scale" : "2x"
},
{
"orientation" : "portrait",
"idiom" : "iphone",
"minimum-system-version" : "7.0",
"scale" : "2x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
<string>${PRODUCT_NAME}</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIcons</key>
<dict/>
<key>CFBundleIcons~ipad</key>
<dict/>
<key>CFBundleIdentifier</key>
<string>org.mitre.${PRODUCT_NAME:rfc1034identifier}</string>
<key>CFBundleInfoDictionaryVersion</key>
Expand Down
Loading

0 comments on commit 76634ec

Please sign in to comment.