Date serialization doesn't work as expected. The objects returned from sqlite is a NSNumber, which is deserialized using [value doubleValue] ; while the values of unpersisted assignments are NSDates thus causing the getter to raise an selector not found exception as the same function is processing different types. Example test fails without change:
describe(@"NSDate", ^{
it(@"Should be saved successfully and return the same date", ^{
User *alex = [User newRecord];
alex.name = @"Alex";
alex.birthDate = [NSDate dateWithTimeIntervalSince1970:0];
BOOL result = [alex save];
User *fetchedUser = [[User allRecords] objectAtIndex:0];
fetchedUser should_not be_nil;
alex.birthDate should equal(fetchedUser.birthDate);
});
});
result would be:
[0;40;31mEXCEPTION NSDate NSDate Should be saved successfully into database
-[__NSDate doubleValue]: unrecognized selector sent to instance 0x8ba0eb0
(null)[0m
Date serialization doesn't work as expected. The objects returned from sqlite is a NSNumber, which is deserialized using [value doubleValue] ; while the values of unpersisted assignments are NSDates thus causing the getter to raise an selector not found exception as the same function is processing different types. Example test fails without change:
result would be:
Solution is to:
Instead of just: