From 15981eb3fbf5438de932c7b815707f3c6a7f0110 Mon Sep 17 00:00:00 2001 From: rowanbeentje Date: Wed, 24 Jun 2009 23:16:39 +0000 Subject: - We have always allowed setting "on update CURRENT_TIMESTAMP" for timestamp columns - parse out this information, and now also show if it's set in the structure view. Fixes the setting not appearing to work. --- Source/SPTableData.m | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'Source/SPTableData.m') diff --git a/Source/SPTableData.m b/Source/SPTableData.m index 3f681b30..0358e984 100644 --- a/Source/SPTableData.m +++ b/Source/SPTableData.m @@ -123,6 +123,7 @@ - (NSDictionary *) columnWithName:(NSString *)colName { int columnIndex = [columnNames indexOfObject:colName]; + if (columnIndex == NSNotFound) return nil; return [columns objectAtIndex:columnIndex]; } @@ -835,6 +836,7 @@ [fieldDetails setValue:[NSNumber numberWithBool:NO] forKey:@"binary"]; [fieldDetails setValue:[NSNumber numberWithBool:NO] forKey:@"zerofill"]; [fieldDetails setValue:[NSNumber numberWithBool:NO] forKey:@"autoincrement"]; + [fieldDetails setValue:[NSNumber numberWithBool:NO] forKey:@"onupdatetimestamp"]; // Walk through the remaining column definition parts storing recognised details partsArrayLength = [definitionParts count]; @@ -893,6 +895,13 @@ [fieldDetails setValue:[detailParser unquotedString] forKey:@"default"]; [detailParser release]; definitionPartsIndex++; + + // Special timestamp case - Whether fields are set to update the current timestamp + } else if ([detailString isEqualToString:@"ON"] && (definitionPartsIndex + 2 < partsArrayLength) + && [[[definitionParts objectAtIndex:definitionPartsIndex+1] uppercaseString] isEqualToString:@"UPDATE"] + && [[[definitionParts objectAtIndex:definitionPartsIndex+2] uppercaseString] isEqualToString:@"CURRENT_TIMESTAMP"]) { + [fieldDetails setValue:[NSNumber numberWithBool:YES] forKey:@"onupdatetimestamp"]; + definitionPartsIndex += 2; } // TODO: Currently unhandled: [UNIQUE | PRIMARY] KEY | COMMENT 'foo' | COLUMN_FORMAT bar | STORAGE q | REFERENCES... -- cgit v1.2.3