From 3adfcf0898f78a8459aedd46be5e89ec906f0314 Mon Sep 17 00:00:00 2001 From: rowanbeentje Date: Mon, 13 Dec 2010 02:25:06 +0000 Subject: - Remove the CURRENT_TIMESTAMP workaround when saving rows as r3013 removes the need for it; this also improves speed slightly as non-changed rows can be skipped much earlier --- Source/SPTableContent.m | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) (limited to 'Source') diff --git a/Source/SPTableContent.m b/Source/SPTableContent.m index 1f4889d7..82282b5d 100644 --- a/Source/SPTableContent.m +++ b/Source/SPTableContent.m @@ -2402,25 +2402,19 @@ // preference setting is enabled, and don't need to be saved back to the table. if ([rowObject isSPNotLoaded]) continue; - // Prepare to derive the value to save, also tracking whether the field has changed. - BOOL fieldValueHasChanged = (isEditingNewRow || ![rowObject isEqual:NSArrayObjectAtIndex(oldRow, i)]); + // If an edit has taken place, and the field value hasn't changed, the value + // can also be skipped + if (!isEditingNewRow && [rowObject isEqual:NSArrayObjectAtIndex(oldRow, i)]) continue; + + // Prepare to derive the value to save NSString *fieldValue; NSString *fieldTypeGroup = [NSArrayObjectAtIndex(dataColumns, i) objectForKey:@"typegrouping"]; - // Catch CURRENT_TIMESTAMP automatic updates - if the row is new and the cell value matches - // the default value, or if the cell hasn't changed, update the current timestamp. - if ([[NSArrayObjectAtIndex(dataColumns, i) objectForKey:@"onupdatetimestamp"] integerValue] - && ( (isEditingNewRow && [rowObject isEqualTo:[NSArrayObjectAtIndex(dataColumns, i) objectForKey:@"default"]]) - || (!isEditingNewRow && [rowObject isEqualTo:NSArrayObjectAtIndex(oldRow, i)]))) - { - fieldValue = @"CURRENT_TIMESTAMP"; - fieldValueHasChanged = YES; - // Use NULL when the user has entered the nullValue string defined in the preferences, // or when a numeric field is empty. - } else if ([rowObject isNSNull] - || (([fieldTypeGroup isEqualToString:@"float"] || [fieldTypeGroup isEqualToString:@"integer"]) - && [[rowObject description] isEqualToString:@""])) + if ([rowObject isNSNull] + || (([fieldTypeGroup isEqualToString:@"float"] || [fieldTypeGroup isEqualToString:@"integer"]) + && [[rowObject description] isEqualToString:@""])) { fieldValue = @"NULL"; @@ -2454,9 +2448,6 @@ } } - // If the field value hasn't changed (only occurs while editing!), continue without saving - if (!fieldValueHasChanged) continue; - // Store the key and value in the ordered arrays for saving. [rowFieldsToSave addObject:[NSArrayObjectAtIndex(dataColumns, i) objectForKey:@"name"]]; [rowValuesToSave addObject:fieldValue]; -- cgit v1.2.3