aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Source/SPTableData.m9
-rw-r--r--Source/TableSource.m8
2 files changed, 17 insertions, 0 deletions
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...
diff --git a/Source/TableSource.m b/Source/TableSource.m
index 3ead57ac..bd48b2ce 100644
--- a/Source/TableSource.m
+++ b/Source/TableSource.m
@@ -149,6 +149,14 @@ loads aTable, put it in an array, update the tableViewColumns and reload the tab
[possibleValues release];
[valueParser release];
}
+
+ // For timestamps check to see whether "on update CURRENT_TIMESTAMP" - not returned
+ // by SHOW COLUMNS - should be set from the table data store
+ if ([type isEqualToString:@"timestamp"]
+ && [[[tableDataInstance columnWithName:[field objectForKey:@"Field"]] objectForKey:@"onupdatetimestamp"] intValue])
+ {
+ [field setObject:@"on update CURRENT_TIMESTAMP" forKey:@"Extra"];
+ }
// scan extras for values like unsigned, zerofill, binary
extrasArray = [extras componentsSeparatedByString:@" "];