aboutsummaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
Diffstat (limited to 'Source')
-rw-r--r--Source/SPTableData.m19
-rw-r--r--Source/TableSource.m29
2 files changed, 45 insertions, 3 deletions
diff --git a/Source/SPTableData.m b/Source/SPTableData.m
index 083de094..66224529 100644
--- a/Source/SPTableData.m
+++ b/Source/SPTableData.m
@@ -410,7 +410,7 @@
// Store the column.
[tableColumns addObject:[NSDictionary dictionaryWithDictionary:tableColumn]];
- // TODO: Otherwise it's a key definition, constraint, check, or other 'metadata'. Would be useful to parse/display these!
+ // TODO: Otherwise it's a key definition, check, or other 'metadata'. Would be useful to parse/display these!
} else {
NSArray *parts = [fieldsParser splitStringByCharacter:' ' skippingBrackets:YES ignoringQuotedStrings:YES];
@@ -866,6 +866,8 @@
[fieldDetails setValue:[NSNumber numberWithBool:NO] forKey:@"zerofill"];
[fieldDetails setValue:[NSNumber numberWithBool:NO] forKey:@"autoincrement"];
[fieldDetails setValue:[NSNumber numberWithBool:NO] forKey:@"onupdatetimestamp"];
+ [fieldDetails setValue:@"" forKey:@"comment"];
+ [fieldDetails setValue:[NSMutableString string] forKey:@"unparsed"];
// Walk through the remaining column definition parts storing recognised details
partsArrayLength = [definitionParts count];
@@ -931,10 +933,21 @@
&& [[[definitionParts objectAtIndex:definitionPartsIndex+2] uppercaseString] isEqualToString:@"CURRENT_TIMESTAMP"]) {
[fieldDetails setValue:[NSNumber numberWithBool:YES] forKey:@"onupdatetimestamp"];
definitionPartsIndex += 2;
+
+ // Column comments
+ } else if ([detailString isEqualToString:@"COMMENT"] && (definitionPartsIndex + 1 < partsArrayLength)) {
+ detailParser = [[SPSQLParser alloc] initWithString:[definitionParts objectAtIndex:definitionPartsIndex+1]];
+ [fieldDetails setValue:[detailParser unquotedString] forKey:@"comment"];
+ [detailParser release];
+ definitionPartsIndex++;
+
+ // Preserve unhandled details to avoid losing information when rearranging columns etc
+ // TODO: Currently unhandled: [UNIQUE | PRIMARY] KEY | COLUMN_FORMAT bar | STORAGE q | REFERENCES...
+ } else {
+ [[fieldDetails objectForKey:@"unparsed"] appendString:@" "];
+ [[fieldDetails objectForKey:@"unparsed"] appendString:[definitionParts objectAtIndex:definitionPartsIndex]];
}
- // TODO: Currently unhandled: [UNIQUE | PRIMARY] KEY | COMMENT 'foo' | COLUMN_FORMAT bar | STORAGE q | REFERENCES...
-
[detailString release];
}
diff --git a/Source/TableSource.m b/Source/TableSource.m
index a2b62787..bc4a9810 100644
--- a/Source/TableSource.m
+++ b/Source/TableSource.m
@@ -754,6 +754,22 @@ fetches the result as an array with a dictionary for each row in it
[queryString appendString:[theRow objectForKey:@"Extra"]];
}
+ if (!isEditingNewRow) {
+
+ // Add details not provided via the SHOW COLUMNS query from the table data cache so column details aren't lost
+ NSDictionary *originalColumnDetails = [[tableDataInstance columns] objectAtIndex:currentlyEditingRow];
+
+ // Any column comments
+ if ([originalColumnDetails objectForKey:@"comment"] && [[originalColumnDetails objectForKey:@"comment"] length]) {
+ [queryString appendString:[NSString stringWithFormat:@" COMMENT '%@'", [mySQLConnection prepareString:[originalColumnDetails objectForKey:@"comment"]]]];
+ }
+
+ // Unparsed details - column formats, storage, reference definitions
+ if ([originalColumnDetails objectForKey:@"unparsed"]) {
+ [queryString appendString:[originalColumnDetails objectForKey:@"unparsed"]];
+ }
+ }
+
// Asks the user to add an index to query if auto_increment is set and field isn't indexed
if ([[theRow objectForKey:@"Extra"] isEqualToString:@"auto_increment"] &&
([[theRow objectForKey:@"Key"] isEqualToString:@""] ||
@@ -1184,6 +1200,19 @@ would result in a position change.
[queryString appendString:[NSString stringWithFormat:@" DEFAULT '%@'", [mySQLConnection prepareString:[originalRow objectForKey:@"Default"]]]];
}
+ // Add details not provided via the SHOW COLUMNS query from the table data cache so column details aren't lost
+ NSDictionary *originalColumnDetails = [[tableDataInstance columns] objectAtIndex:originalRowIndex];
+
+ // Any column comments
+ if ([originalColumnDetails objectForKey:@"comment"] && [[originalColumnDetails objectForKey:@"comment"] length]) {
+ [queryString appendString:[NSString stringWithFormat:@" COMMENT '%@'", [mySQLConnection prepareString:[originalColumnDetails objectForKey:@"comment"]]]];
+ }
+
+ // Unparsed details - column formats, storage, reference definitions
+ if ([originalColumnDetails objectForKey:@"unparsed"]) {
+ [queryString appendString:[originalColumnDetails objectForKey:@"unparsed"]];
+ }
+
// Add the new location
if ( destinationRowIndex == 0 ){
[queryString appendString:@" FIRST"];