SkygearIO / skygear-SDK-iOS

Skygear SDK for iOS
https://skygear.io
Other
10 stars 28 forks source link

CreationDate should not be assigned to a locally newly created record #146

Open Steven-Chan opened 6 years ago

Steven-Chan commented 6 years ago

The following code is in SKYDatabase.m. And this function is called before saving the record to server.

- (void)od_prepareRecordForSaving:(SKYRecord *)record
{
    if (![record isKindOfClass:[SKYRecord class]]) {
        NSString *reason =
            [NSString stringWithFormat:@"The given object %@ is not an SKYRecord.", record];
        @throw
            [NSException exceptionWithName:NSInvalidArgumentException reason:reason userInfo:nil];
    }

    if (!record.creationDate) {
        record.creationDate = [NSDate date];
    }
}

Last commit of these lines is 3 years ago, and the commit message of this logic is Copy ODKit source from AskQ. Also I cannot find the same logic in other SDK.

How I found this thing

I was testing my chat cache code with error response. I expected the creationDate of the record would be nil, but I found its not.