diff --git a/MagicalRecord/Categories/DataImport/MagicalImportFunctions.h b/MagicalRecord/Categories/DataImport/MagicalImportFunctions.h index 4a947b71f..f7d52da0a 100644 --- a/MagicalRecord/Categories/DataImport/MagicalImportFunctions.h +++ b/MagicalRecord/Categories/DataImport/MagicalImportFunctions.h @@ -11,6 +11,7 @@ NSDate * adjustDateForDST(NSDate *date); NSDate * dateFromString(NSString *value, NSString *format); +NSNumber * numberFromString(NSString *value); NSString * attributeNameFromString(NSString *value); NSString * primaryKeyNameFromString(NSString *value); diff --git a/MagicalRecord/Categories/DataImport/MagicalImportFunctions.m b/MagicalRecord/Categories/DataImport/MagicalImportFunctions.m index 4c15a0989..0f4f1962d 100644 --- a/MagicalRecord/Categories/DataImport/MagicalImportFunctions.m +++ b/MagicalRecord/Categories/DataImport/MagicalImportFunctions.m @@ -43,6 +43,10 @@ return parsedDate; } +NSNumber * numberFromString(NSString *value) { + return [NSNumber numberWithDouble:[value doubleValue]]; +} + NSInteger* newColorComponentsFromString(NSString *serializedColor); NSInteger* newColorComponentsFromString(NSString *serializedColor) { diff --git a/MagicalRecord/Categories/DataImport/NSAttributeDescription+MagicalDataImport.m b/MagicalRecord/Categories/DataImport/NSAttributeDescription+MagicalDataImport.m index af10f0612..a0395025a 100644 --- a/MagicalRecord/Categories/DataImport/NSAttributeDescription+MagicalDataImport.m +++ b/MagicalRecord/Categories/DataImport/NSAttributeDescription+MagicalDataImport.m @@ -41,6 +41,16 @@ - (id) MR_valueForKeyPath:(NSString *)keyPath fromObjectData:(id)objectData; } // value = adjustDateForDST(value); } + else if (attributeType == NSInteger16AttributeType || + attributeType == NSInteger32AttributeType || + attributeType == NSInteger64AttributeType || + attributeType == NSDecimalAttributeType || + attributeType == NSDoubleAttributeType || + attributeType == NSFloatAttributeType) { + if (![value isKindOfClass:[NSNumber class]] && value != [NSNull null]) { + value = numberFromString([value description]); + } + } } return value == [NSNull null] ? nil : value; diff --git a/MagicalRecord/Categories/DataImport/NSString+MagicalDataImport.m b/MagicalRecord/Categories/DataImport/NSString+MagicalDataImport.m index 065ddc268..6af78dbb1 100644 --- a/MagicalRecord/Categories/DataImport/NSString+MagicalDataImport.m +++ b/MagicalRecord/Categories/DataImport/NSString+MagicalDataImport.m @@ -21,5 +21,15 @@ - (NSString *) MR_capitalizedFirstCharacterString; return self; } +- (id) MR_relatedValueForRelationship:(NSRelationshipDescription *)relationshipInfo +{ + return self; +} + +- (NSString *) MR_lookupKeyForAttribute:(NSAttributeDescription *)attributeInfo +{ + return nil; +} + @end diff --git a/MagicalRecord/Categories/NSManagedObject/NSManagedObject+MagicalDataImport.m b/MagicalRecord/Categories/NSManagedObject/NSManagedObject+MagicalDataImport.m index 368bba8a0..4e5fb5c01 100644 --- a/MagicalRecord/Categories/NSManagedObject/NSManagedObject+MagicalDataImport.m +++ b/MagicalRecord/Categories/NSManagedObject/NSManagedObject+MagicalDataImport.m @@ -154,7 +154,7 @@ - (void) MR_setRelationships:(NSDictionary *)relationships forKeysWithObject:(id } }; - if ([relationshipInfo isToMany]) + if ([relationshipInfo isToMany] && [relatedObjectData isKindOfClass:[NSArray class]]) { for (id singleRelatedObjectData in relatedObjectData) { diff --git a/Project Files/TestModel.xcdatamodeld/TestModel.xcdatamodel/contents b/Project Files/TestModel.xcdatamodeld/TestModel.xcdatamodel/contents index ccc919d65..04ae7df90 100644 --- a/Project Files/TestModel.xcdatamodeld/TestModel.xcdatamodel/contents +++ b/Project Files/TestModel.xcdatamodeld/TestModel.xcdatamodel/contents @@ -1,5 +1,5 @@ - + @@ -105,21 +105,39 @@ + + + + + + + + + + + + + + + + + + @@ -167,7 +185,7 @@ - + \ No newline at end of file diff --git a/Project Files/Unit Tests/Fixtures/SingleEntityWithNoRelationships.json b/Project Files/Unit Tests/Fixtures/SingleEntityWithNoRelationships.json index 9ec1cc14e..d41e5b282 100644 --- a/Project Files/Unit Tests/Fixtures/SingleEntityWithNoRelationships.json +++ b/Project Files/Unit Tests/Fixtures/SingleEntityWithNoRelationships.json @@ -11,5 +11,12 @@ "colorTestAttribute": "rgba(64,128,225,1)", "mappedAttributeWithStringValue": "Mapped value", "dateWithCustomFormat": "8/5/2011 1-56-04 AM", - "nullTestAttribute": null + "nullTestAttribute": null, + "int64AsStringTestAttribute": "42", + "int32AsStringTestAttribute": "32", + "int16AsStringTestAttribute": "256", + "decimalAsStringTestAttribute": "1.2", + "doubleAsStringTestAttribute": "124.3", + "floatAsStringTestAttribute": "10000000000", + } \ No newline at end of file diff --git a/Project Files/Unit Tests/Fixtures/iOS/TestEntities/_SingleEntityWithNoRelationships.h b/Project Files/Unit Tests/Fixtures/iOS/TestEntities/_SingleEntityWithNoRelationships.h index 03cc330ac..2d71518a8 100644 --- a/Project Files/Unit Tests/Fixtures/iOS/TestEntities/_SingleEntityWithNoRelationships.h +++ b/Project Files/Unit Tests/Fixtures/iOS/TestEntities/_SingleEntityWithNoRelationships.h @@ -9,11 +9,17 @@ extern const struct SingleEntityWithNoRelationshipsAttributes { __unsafe_unretained NSString *colorTestAttribute; __unsafe_unretained NSString *dateTestAttribute; __unsafe_unretained NSString *dateWithCustomFormat; + __unsafe_unretained NSString *decimalAsStringTestAttribute; __unsafe_unretained NSString *decimalTestAttribute; + __unsafe_unretained NSString *doubleAsStringTestAttribute; __unsafe_unretained NSString *doubleTestAttribute; + __unsafe_unretained NSString *floatAsStringTestAttribute; __unsafe_unretained NSString *floatTestAttribute; + __unsafe_unretained NSString *int16AsStringTestAttribute; __unsafe_unretained NSString *int16TestAttribute; + __unsafe_unretained NSString *int32AsStringTestAttribute; __unsafe_unretained NSString *int32TestAttribute; + __unsafe_unretained NSString *int64AsStringTestAttribute; __unsafe_unretained NSString *int64TestAttribute; __unsafe_unretained NSString *mappedStringAttribute; __unsafe_unretained NSString *notInJsonAttribute; @@ -29,7 +35,13 @@ extern const struct SingleEntityWithNoRelationshipsFetchedProperties { -@class UIColor; +@class NSObject; + + + + + + @@ -55,7 +67,7 @@ extern const struct SingleEntityWithNoRelationshipsFetchedProperties { -@property (nonatomic, strong) NSNumber *booleanTestAttribute; +@property (nonatomic, strong) NSNumber* booleanTestAttribute; @property BOOL booleanTestAttributeValue; @@ -67,7 +79,7 @@ extern const struct SingleEntityWithNoRelationshipsFetchedProperties { -@property (nonatomic, strong) UIColor *colorTestAttribute; +@property (nonatomic, strong) id colorTestAttribute; //- (BOOL)validateColorTestAttribute:(id*)value_ error:(NSError**)error_; @@ -75,7 +87,7 @@ extern const struct SingleEntityWithNoRelationshipsFetchedProperties { -@property (nonatomic, strong) NSDate *dateTestAttribute; +@property (nonatomic, strong) NSDate* dateTestAttribute; //- (BOOL)validateDateTestAttribute:(id*)value_ error:(NSError**)error_; @@ -83,7 +95,7 @@ extern const struct SingleEntityWithNoRelationshipsFetchedProperties { -@property (nonatomic, strong) NSDate *dateWithCustomFormat; +@property (nonatomic, strong) NSDate* dateWithCustomFormat; //- (BOOL)validateDateWithCustomFormat:(id*)value_ error:(NSError**)error_; @@ -91,7 +103,15 @@ extern const struct SingleEntityWithNoRelationshipsFetchedProperties { -@property (nonatomic, strong) NSDecimalNumber *decimalTestAttribute; +@property (nonatomic, strong) NSDecimalNumber* decimalAsStringTestAttribute; + + +//- (BOOL)validateDecimalAsStringTestAttribute:(id*)value_ error:(NSError**)error_; + + + + +@property (nonatomic, strong) NSDecimalNumber* decimalTestAttribute; //- (BOOL)validateDecimalTestAttribute:(id*)value_ error:(NSError**)error_; @@ -99,7 +119,19 @@ extern const struct SingleEntityWithNoRelationshipsFetchedProperties { -@property (nonatomic, strong) NSNumber *doubleTestAttribute; +@property (nonatomic, strong) NSNumber* doubleAsStringTestAttribute; + + +@property double doubleAsStringTestAttributeValue; +- (double)doubleAsStringTestAttributeValue; +- (void)setDoubleAsStringTestAttributeValue:(double)value_; + +//- (BOOL)validateDoubleAsStringTestAttribute:(id*)value_ error:(NSError**)error_; + + + + +@property (nonatomic, strong) NSNumber* doubleTestAttribute; @property double doubleTestAttributeValue; @@ -111,7 +143,19 @@ extern const struct SingleEntityWithNoRelationshipsFetchedProperties { -@property (nonatomic, strong) NSNumber *floatTestAttribute; +@property (nonatomic, strong) NSNumber* floatAsStringTestAttribute; + + +@property float floatAsStringTestAttributeValue; +- (float)floatAsStringTestAttributeValue; +- (void)setFloatAsStringTestAttributeValue:(float)value_; + +//- (BOOL)validateFloatAsStringTestAttribute:(id*)value_ error:(NSError**)error_; + + + + +@property (nonatomic, strong) NSNumber* floatTestAttribute; @property float floatTestAttributeValue; @@ -123,43 +167,79 @@ extern const struct SingleEntityWithNoRelationshipsFetchedProperties { -@property (nonatomic, strong) NSNumber *int16TestAttribute; +@property (nonatomic, strong) NSNumber* int16AsStringTestAttribute; + + +@property int16_t int16AsStringTestAttributeValue; +- (int16_t)int16AsStringTestAttributeValue; +- (void)setInt16AsStringTestAttributeValue:(int16_t)value_; + +//- (BOOL)validateInt16AsStringTestAttribute:(id*)value_ error:(NSError**)error_; + -@property short int16TestAttributeValue; -- (short)int16TestAttributeValue; -- (void)setInt16TestAttributeValue:(short)value_; + +@property (nonatomic, strong) NSNumber* int16TestAttribute; + + +@property int16_t int16TestAttributeValue; +- (int16_t)int16TestAttributeValue; +- (void)setInt16TestAttributeValue:(int16_t)value_; //- (BOOL)validateInt16TestAttribute:(id*)value_ error:(NSError**)error_; -@property (nonatomic, strong) NSNumber *int32TestAttribute; +@property (nonatomic, strong) NSNumber* int32AsStringTestAttribute; + + +@property int32_t int32AsStringTestAttributeValue; +- (int32_t)int32AsStringTestAttributeValue; +- (void)setInt32AsStringTestAttributeValue:(int32_t)value_; + +//- (BOOL)validateInt32AsStringTestAttribute:(id*)value_ error:(NSError**)error_; + + + +@property (nonatomic, strong) NSNumber* int32TestAttribute; -@property int int32TestAttributeValue; -- (int)int32TestAttributeValue; -- (void)setInt32TestAttributeValue:(int)value_; + +@property int32_t int32TestAttributeValue; +- (int32_t)int32TestAttributeValue; +- (void)setInt32TestAttributeValue:(int32_t)value_; //- (BOOL)validateInt32TestAttribute:(id*)value_ error:(NSError**)error_; -@property (nonatomic, strong) NSNumber *int64TestAttribute; +@property (nonatomic, strong) NSNumber* int64AsStringTestAttribute; + + +@property int64_t int64AsStringTestAttributeValue; +- (int64_t)int64AsStringTestAttributeValue; +- (void)setInt64AsStringTestAttributeValue:(int64_t)value_; + +//- (BOOL)validateInt64AsStringTestAttribute:(id*)value_ error:(NSError**)error_; + -@property long long int64TestAttributeValue; -- (long long)int64TestAttributeValue; -- (void)setInt64TestAttributeValue:(long long)value_; + +@property (nonatomic, strong) NSNumber* int64TestAttribute; + + +@property int64_t int64TestAttributeValue; +- (int64_t)int64TestAttributeValue; +- (void)setInt64TestAttributeValue:(int64_t)value_; //- (BOOL)validateInt64TestAttribute:(id*)value_ error:(NSError**)error_; -@property (nonatomic, strong) NSString *mappedStringAttribute; +@property (nonatomic, strong) NSString* mappedStringAttribute; //- (BOOL)validateMappedStringAttribute:(id*)value_ error:(NSError**)error_; @@ -167,7 +247,7 @@ extern const struct SingleEntityWithNoRelationshipsFetchedProperties { -@property (nonatomic, strong) NSString *notInJsonAttribute; +@property (nonatomic, strong) NSString* notInJsonAttribute; //- (BOOL)validateNotInJsonAttribute:(id*)value_ error:(NSError**)error_; @@ -175,19 +255,19 @@ extern const struct SingleEntityWithNoRelationshipsFetchedProperties { -@property (nonatomic, strong) NSNumber *nullTestAttribute; +@property (nonatomic, strong) NSNumber* nullTestAttribute; -@property long long nullTestAttributeValue; -- (long long)nullTestAttributeValue; -- (void)setNullTestAttributeValue:(long long)value_; +@property int64_t nullTestAttributeValue; +- (int64_t)nullTestAttributeValue; +- (void)setNullTestAttributeValue:(int64_t)value_; //- (BOOL)validateNullTestAttribute:(id*)value_ error:(NSError**)error_; -@property (nonatomic, strong) NSString *stringTestAttribute; +@property (nonatomic, strong) NSString* stringTestAttribute; //- (BOOL)validateStringTestAttribute:(id*)value_ error:(NSError**)error_; @@ -196,6 +276,7 @@ extern const struct SingleEntityWithNoRelationshipsFetchedProperties { + @end @interface _SingleEntityWithNoRelationships (CoreDataGeneratedAccessors) @@ -214,8 +295,8 @@ extern const struct SingleEntityWithNoRelationshipsFetchedProperties { -- (UIColor*)primitiveColorTestAttribute; -- (void)setPrimitiveColorTestAttribute:(UIColor*)value; +- (id)primitiveColorTestAttribute; +- (void)setPrimitiveColorTestAttribute:(id)value; @@ -232,12 +313,27 @@ extern const struct SingleEntityWithNoRelationshipsFetchedProperties { +- (NSDecimalNumber*)primitiveDecimalAsStringTestAttribute; +- (void)setPrimitiveDecimalAsStringTestAttribute:(NSDecimalNumber*)value; + + + + - (NSDecimalNumber*)primitiveDecimalTestAttribute; - (void)setPrimitiveDecimalTestAttribute:(NSDecimalNumber*)value; +- (NSNumber*)primitiveDoubleAsStringTestAttribute; +- (void)setPrimitiveDoubleAsStringTestAttribute:(NSNumber*)value; + +- (double)primitiveDoubleAsStringTestAttributeValue; +- (void)setPrimitiveDoubleAsStringTestAttributeValue:(double)value_; + + + + - (NSNumber*)primitiveDoubleTestAttribute; - (void)setPrimitiveDoubleTestAttribute:(NSNumber*)value; @@ -247,6 +343,15 @@ extern const struct SingleEntityWithNoRelationshipsFetchedProperties { +- (NSNumber*)primitiveFloatAsStringTestAttribute; +- (void)setPrimitiveFloatAsStringTestAttribute:(NSNumber*)value; + +- (float)primitiveFloatAsStringTestAttributeValue; +- (void)setPrimitiveFloatAsStringTestAttributeValue:(float)value_; + + + + - (NSNumber*)primitiveFloatTestAttribute; - (void)setPrimitiveFloatTestAttribute:(NSNumber*)value; @@ -256,11 +361,29 @@ extern const struct SingleEntityWithNoRelationshipsFetchedProperties { +- (NSNumber*)primitiveInt16AsStringTestAttribute; +- (void)setPrimitiveInt16AsStringTestAttribute:(NSNumber*)value; + +- (int16_t)primitiveInt16AsStringTestAttributeValue; +- (void)setPrimitiveInt16AsStringTestAttributeValue:(int16_t)value_; + + + + - (NSNumber*)primitiveInt16TestAttribute; - (void)setPrimitiveInt16TestAttribute:(NSNumber*)value; -- (short)primitiveInt16TestAttributeValue; -- (void)setPrimitiveInt16TestAttributeValue:(short)value_; +- (int16_t)primitiveInt16TestAttributeValue; +- (void)setPrimitiveInt16TestAttributeValue:(int16_t)value_; + + + + +- (NSNumber*)primitiveInt32AsStringTestAttribute; +- (void)setPrimitiveInt32AsStringTestAttribute:(NSNumber*)value; + +- (int32_t)primitiveInt32AsStringTestAttributeValue; +- (void)setPrimitiveInt32AsStringTestAttributeValue:(int32_t)value_; @@ -268,8 +391,17 @@ extern const struct SingleEntityWithNoRelationshipsFetchedProperties { - (NSNumber*)primitiveInt32TestAttribute; - (void)setPrimitiveInt32TestAttribute:(NSNumber*)value; -- (int)primitiveInt32TestAttributeValue; -- (void)setPrimitiveInt32TestAttributeValue:(int)value_; +- (int32_t)primitiveInt32TestAttributeValue; +- (void)setPrimitiveInt32TestAttributeValue:(int32_t)value_; + + + + +- (NSNumber*)primitiveInt64AsStringTestAttribute; +- (void)setPrimitiveInt64AsStringTestAttribute:(NSNumber*)value; + +- (int64_t)primitiveInt64AsStringTestAttributeValue; +- (void)setPrimitiveInt64AsStringTestAttributeValue:(int64_t)value_; @@ -277,8 +409,8 @@ extern const struct SingleEntityWithNoRelationshipsFetchedProperties { - (NSNumber*)primitiveInt64TestAttribute; - (void)setPrimitiveInt64TestAttribute:(NSNumber*)value; -- (long long)primitiveInt64TestAttributeValue; -- (void)setPrimitiveInt64TestAttributeValue:(long long)value_; +- (int64_t)primitiveInt64TestAttributeValue; +- (void)setPrimitiveInt64TestAttributeValue:(int64_t)value_; @@ -298,8 +430,8 @@ extern const struct SingleEntityWithNoRelationshipsFetchedProperties { - (NSNumber*)primitiveNullTestAttribute; - (void)setPrimitiveNullTestAttribute:(NSNumber*)value; -- (long long)primitiveNullTestAttributeValue; -- (void)setPrimitiveNullTestAttributeValue:(long long)value_; +- (int64_t)primitiveNullTestAttributeValue; +- (void)setPrimitiveNullTestAttributeValue:(int64_t)value_; diff --git a/Project Files/Unit Tests/Fixtures/iOS/TestEntities/_SingleEntityWithNoRelationships.m b/Project Files/Unit Tests/Fixtures/iOS/TestEntities/_SingleEntityWithNoRelationships.m index 8c6a28719..b372819da 100644 --- a/Project Files/Unit Tests/Fixtures/iOS/TestEntities/_SingleEntityWithNoRelationships.m +++ b/Project Files/Unit Tests/Fixtures/iOS/TestEntities/_SingleEntityWithNoRelationships.m @@ -8,11 +8,17 @@ .colorTestAttribute = @"colorTestAttribute", .dateTestAttribute = @"dateTestAttribute", .dateWithCustomFormat = @"dateWithCustomFormat", + .decimalAsStringTestAttribute = @"decimalAsStringTestAttribute", .decimalTestAttribute = @"decimalTestAttribute", + .doubleAsStringTestAttribute = @"doubleAsStringTestAttribute", .doubleTestAttribute = @"doubleTestAttribute", + .floatAsStringTestAttribute = @"floatAsStringTestAttribute", .floatTestAttribute = @"floatTestAttribute", + .int16AsStringTestAttribute = @"int16AsStringTestAttribute", .int16TestAttribute = @"int16TestAttribute", + .int32AsStringTestAttribute = @"int32AsStringTestAttribute", .int32TestAttribute = @"int32TestAttribute", + .int64AsStringTestAttribute = @"int64AsStringTestAttribute", .int64TestAttribute = @"int64TestAttribute", .mappedStringAttribute = @"mappedStringAttribute", .notInJsonAttribute = @"notInJsonAttribute", @@ -56,22 +62,42 @@ + (NSSet *)keyPathsForValuesAffectingValueForKey:(NSString *)key { NSSet *affectingKey = [NSSet setWithObject:@"booleanTestAttribute"]; keyPaths = [keyPaths setByAddingObjectsFromSet:affectingKey]; } + if ([key isEqualToString:@"doubleAsStringTestAttributeValue"]) { + NSSet *affectingKey = [NSSet setWithObject:@"doubleAsStringTestAttribute"]; + keyPaths = [keyPaths setByAddingObjectsFromSet:affectingKey]; + } if ([key isEqualToString:@"doubleTestAttributeValue"]) { NSSet *affectingKey = [NSSet setWithObject:@"doubleTestAttribute"]; keyPaths = [keyPaths setByAddingObjectsFromSet:affectingKey]; } + if ([key isEqualToString:@"floatAsStringTestAttributeValue"]) { + NSSet *affectingKey = [NSSet setWithObject:@"floatAsStringTestAttribute"]; + keyPaths = [keyPaths setByAddingObjectsFromSet:affectingKey]; + } if ([key isEqualToString:@"floatTestAttributeValue"]) { NSSet *affectingKey = [NSSet setWithObject:@"floatTestAttribute"]; keyPaths = [keyPaths setByAddingObjectsFromSet:affectingKey]; } + if ([key isEqualToString:@"int16AsStringTestAttributeValue"]) { + NSSet *affectingKey = [NSSet setWithObject:@"int16AsStringTestAttribute"]; + keyPaths = [keyPaths setByAddingObjectsFromSet:affectingKey]; + } if ([key isEqualToString:@"int16TestAttributeValue"]) { NSSet *affectingKey = [NSSet setWithObject:@"int16TestAttribute"]; keyPaths = [keyPaths setByAddingObjectsFromSet:affectingKey]; } + if ([key isEqualToString:@"int32AsStringTestAttributeValue"]) { + NSSet *affectingKey = [NSSet setWithObject:@"int32AsStringTestAttribute"]; + keyPaths = [keyPaths setByAddingObjectsFromSet:affectingKey]; + } if ([key isEqualToString:@"int32TestAttributeValue"]) { NSSet *affectingKey = [NSSet setWithObject:@"int32TestAttribute"]; keyPaths = [keyPaths setByAddingObjectsFromSet:affectingKey]; } + if ([key isEqualToString:@"int64AsStringTestAttributeValue"]) { + NSSet *affectingKey = [NSSet setWithObject:@"int64AsStringTestAttribute"]; + keyPaths = [keyPaths setByAddingObjectsFromSet:affectingKey]; + } if ([key isEqualToString:@"int64TestAttributeValue"]) { NSSet *affectingKey = [NSSet setWithObject:@"int64TestAttribute"]; keyPaths = [keyPaths setByAddingObjectsFromSet:affectingKey]; @@ -134,6 +160,13 @@ - (void)setPrimitiveBooleanTestAttributeValue:(BOOL)value_ { +@dynamic decimalAsStringTestAttribute; + + + + + + @dynamic decimalTestAttribute; @@ -141,6 +174,32 @@ - (void)setPrimitiveBooleanTestAttributeValue:(BOOL)value_ { +@dynamic doubleAsStringTestAttribute; + + + +- (double)doubleAsStringTestAttributeValue { + NSNumber *result = [self doubleAsStringTestAttribute]; + return [result doubleValue]; +} + +- (void)setDoubleAsStringTestAttributeValue:(double)value_ { + [self setDoubleAsStringTestAttribute:[NSNumber numberWithDouble:value_]]; +} + +- (double)primitiveDoubleAsStringTestAttributeValue { + NSNumber *result = [self primitiveDoubleAsStringTestAttribute]; + return [result doubleValue]; +} + +- (void)setPrimitiveDoubleAsStringTestAttributeValue:(double)value_ { + [self setPrimitiveDoubleAsStringTestAttribute:[NSNumber numberWithDouble:value_]]; +} + + + + + @dynamic doubleTestAttribute; @@ -167,6 +226,32 @@ - (void)setPrimitiveDoubleTestAttributeValue:(double)value_ { +@dynamic floatAsStringTestAttribute; + + + +- (float)floatAsStringTestAttributeValue { + NSNumber *result = [self floatAsStringTestAttribute]; + return [result floatValue]; +} + +- (void)setFloatAsStringTestAttributeValue:(float)value_ { + [self setFloatAsStringTestAttribute:[NSNumber numberWithFloat:value_]]; +} + +- (float)primitiveFloatAsStringTestAttributeValue { + NSNumber *result = [self primitiveFloatAsStringTestAttribute]; + return [result floatValue]; +} + +- (void)setPrimitiveFloatAsStringTestAttributeValue:(float)value_ { + [self setPrimitiveFloatAsStringTestAttribute:[NSNumber numberWithFloat:value_]]; +} + + + + + @dynamic floatTestAttribute; @@ -193,25 +278,51 @@ - (void)setPrimitiveFloatTestAttributeValue:(float)value_ { +@dynamic int16AsStringTestAttribute; + + + +- (int16_t)int16AsStringTestAttributeValue { + NSNumber *result = [self int16AsStringTestAttribute]; + return [result shortValue]; +} + +- (void)setInt16AsStringTestAttributeValue:(int16_t)value_ { + [self setInt16AsStringTestAttribute:[NSNumber numberWithShort:value_]]; +} + +- (int16_t)primitiveInt16AsStringTestAttributeValue { + NSNumber *result = [self primitiveInt16AsStringTestAttribute]; + return [result shortValue]; +} + +- (void)setPrimitiveInt16AsStringTestAttributeValue:(int16_t)value_ { + [self setPrimitiveInt16AsStringTestAttribute:[NSNumber numberWithShort:value_]]; +} + + + + + @dynamic int16TestAttribute; -- (short)int16TestAttributeValue { +- (int16_t)int16TestAttributeValue { NSNumber *result = [self int16TestAttribute]; return [result shortValue]; } -- (void)setInt16TestAttributeValue:(short)value_ { +- (void)setInt16TestAttributeValue:(int16_t)value_ { [self setInt16TestAttribute:[NSNumber numberWithShort:value_]]; } -- (short)primitiveInt16TestAttributeValue { +- (int16_t)primitiveInt16TestAttributeValue { NSNumber *result = [self primitiveInt16TestAttribute]; return [result shortValue]; } -- (void)setPrimitiveInt16TestAttributeValue:(short)value_ { +- (void)setPrimitiveInt16TestAttributeValue:(int16_t)value_ { [self setPrimitiveInt16TestAttribute:[NSNumber numberWithShort:value_]]; } @@ -219,25 +330,51 @@ - (void)setPrimitiveInt16TestAttributeValue:(short)value_ { +@dynamic int32AsStringTestAttribute; + + + +- (int32_t)int32AsStringTestAttributeValue { + NSNumber *result = [self int32AsStringTestAttribute]; + return [result intValue]; +} + +- (void)setInt32AsStringTestAttributeValue:(int32_t)value_ { + [self setInt32AsStringTestAttribute:[NSNumber numberWithInt:value_]]; +} + +- (int32_t)primitiveInt32AsStringTestAttributeValue { + NSNumber *result = [self primitiveInt32AsStringTestAttribute]; + return [result intValue]; +} + +- (void)setPrimitiveInt32AsStringTestAttributeValue:(int32_t)value_ { + [self setPrimitiveInt32AsStringTestAttribute:[NSNumber numberWithInt:value_]]; +} + + + + + @dynamic int32TestAttribute; -- (int)int32TestAttributeValue { +- (int32_t)int32TestAttributeValue { NSNumber *result = [self int32TestAttribute]; return [result intValue]; } -- (void)setInt32TestAttributeValue:(int)value_ { +- (void)setInt32TestAttributeValue:(int32_t)value_ { [self setInt32TestAttribute:[NSNumber numberWithInt:value_]]; } -- (int)primitiveInt32TestAttributeValue { +- (int32_t)primitiveInt32TestAttributeValue { NSNumber *result = [self primitiveInt32TestAttribute]; return [result intValue]; } -- (void)setPrimitiveInt32TestAttributeValue:(int)value_ { +- (void)setPrimitiveInt32TestAttributeValue:(int32_t)value_ { [self setPrimitiveInt32TestAttribute:[NSNumber numberWithInt:value_]]; } @@ -245,25 +382,51 @@ - (void)setPrimitiveInt32TestAttributeValue:(int)value_ { +@dynamic int64AsStringTestAttribute; + + + +- (int64_t)int64AsStringTestAttributeValue { + NSNumber *result = [self int64AsStringTestAttribute]; + return [result longLongValue]; +} + +- (void)setInt64AsStringTestAttributeValue:(int64_t)value_ { + [self setInt64AsStringTestAttribute:[NSNumber numberWithLongLong:value_]]; +} + +- (int64_t)primitiveInt64AsStringTestAttributeValue { + NSNumber *result = [self primitiveInt64AsStringTestAttribute]; + return [result longLongValue]; +} + +- (void)setPrimitiveInt64AsStringTestAttributeValue:(int64_t)value_ { + [self setPrimitiveInt64AsStringTestAttribute:[NSNumber numberWithLongLong:value_]]; +} + + + + + @dynamic int64TestAttribute; -- (long long)int64TestAttributeValue { +- (int64_t)int64TestAttributeValue { NSNumber *result = [self int64TestAttribute]; return [result longLongValue]; } -- (void)setInt64TestAttributeValue:(long long)value_ { +- (void)setInt64TestAttributeValue:(int64_t)value_ { [self setInt64TestAttribute:[NSNumber numberWithLongLong:value_]]; } -- (long long)primitiveInt64TestAttributeValue { +- (int64_t)primitiveInt64TestAttributeValue { NSNumber *result = [self primitiveInt64TestAttribute]; return [result longLongValue]; } -- (void)setPrimitiveInt64TestAttributeValue:(long long)value_ { +- (void)setPrimitiveInt64TestAttributeValue:(int64_t)value_ { [self setPrimitiveInt64TestAttribute:[NSNumber numberWithLongLong:value_]]; } @@ -289,21 +452,21 @@ - (void)setPrimitiveInt64TestAttributeValue:(long long)value_ { -- (long long)nullTestAttributeValue { +- (int64_t)nullTestAttributeValue { NSNumber *result = [self nullTestAttribute]; return [result longLongValue]; } -- (void)setNullTestAttributeValue:(long long)value_ { +- (void)setNullTestAttributeValue:(int64_t)value_ { [self setNullTestAttribute:[NSNumber numberWithLongLong:value_]]; } -- (long long)primitiveNullTestAttributeValue { +- (int64_t)primitiveNullTestAttributeValue { NSNumber *result = [self primitiveNullTestAttribute]; return [result longLongValue]; } -- (void)setPrimitiveNullTestAttributeValue:(long long)value_ { +- (void)setPrimitiveNullTestAttributeValue:(int64_t)value_ { [self setPrimitiveNullTestAttribute:[NSNumber numberWithLongLong:value_]]; } @@ -322,4 +485,5 @@ - (void)setPrimitiveNullTestAttributeValue:(long long)value_ { + @end diff --git a/Project Files/Unit Tests/ImportSingleEntityWithNoRelationshipsTests.m b/Project Files/Unit Tests/ImportSingleEntityWithNoRelationshipsTests.m index 590c97837..b4f379962 100644 --- a/Project Files/Unit Tests/ImportSingleEntityWithNoRelationshipsTests.m +++ b/Project Files/Unit Tests/ImportSingleEntityWithNoRelationshipsTests.m @@ -160,4 +160,34 @@ - (void) testImportDateAttributeWithCustomFormat } +- (void) testImportInt16AsStringAttributeToEntity +{ + assertThat(testEntity.int16AsStringTestAttribute, is(equalToInteger(256))); +} + +- (void) testImportInt32AsStringAttributeToEntity +{ + assertThat(testEntity.int32AsStringTestAttribute, is(equalToInt(32))); +} + +- (void) testImportInt64AsStringAttributeToEntity +{ + assertThat(testEntity.int64AsStringTestAttribute, is(equalToInteger(42))); +} + +- (void) testImportDecimalAsStringAttributeToEntity +{ + assertThat(testEntity.decimalAsStringTestAttribute, is(equalToDouble(1.2))); +} + +- (void) testImportDoubleAsStringAttributeToEntity +{ + assertThat(testEntity.doubleAsStringTestAttribute, is(equalToDouble(124.3))); +} + +- (void) testImportFloatAsStringAttributeToEntity +{ + assertThat(testEntity.floatAsStringTestAttribute, is(equalToFloat(10000000000))); +} + @end