aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPTableStructureDelegate.m
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2010-11-01 11:04:01 +0000
committerBibiko <bibiko@eva.mpg.de>2010-11-01 11:04:01 +0000
commit7587849d307c6c0a7fa11ddbc2ee48af87ab9087 (patch)
tree3ae2092799de52002d553baa463a0c04878439f1 /Source/SPTableStructureDelegate.m
parenta6325dbb88629e7bc5e170bb23955ebf1910c17b (diff)
downloadsequelpro-7587849d307c6c0a7fa11ddbc2ee48af87ab9087.tar.gz
sequelpro-7587849d307c6c0a7fa11ddbc2ee48af87ab9087.tar.bz2
sequelpro-7587849d307c6c0a7fa11ddbc2ee48af87ab9087.zip
• improved Structure editing logic to allow to choose auto_increment for Extra only if table has no auto_increment field set since MySQL allows only one auto column
- the user has still the chance to type 'auto_increment' into the Extra manually
Diffstat (limited to 'Source/SPTableStructureDelegate.m')
-rw-r--r--Source/SPTableStructureDelegate.m27
1 files changed, 23 insertions, 4 deletions
diff --git a/Source/SPTableStructureDelegate.m b/Source/SPTableStructureDelegate.m
index b3246ca2..bdc3cb3f 100644
--- a/Source/SPTableStructureDelegate.m
+++ b/Source/SPTableStructureDelegate.m
@@ -65,7 +65,18 @@
[[tableColumn dataCell] addItemWithTitle:[collation objectForKey:@"COLLATION_NAME"]];
}
}
-
+
+ else if([[tableColumn identifier] isEqualToString:@"Extra"]) {
+ id dataCell = [tableColumn dataCell];
+ [dataCell removeAllItems];
+ // Populate Extra suggestion popup button
+ for (id item in extraFieldSuggestions) {
+ if(!(isCurrentExtraAutoIncrement && [item isEqualToString:@"auto_increment"])) {
+ [dataCell addItemWithObjectValue:item];
+ }
+ }
+ }
+
return [NSArrayObjectAtIndex(tableFields, rowIndex) objectForKey:[tableColumn identifier]];
}
@@ -98,13 +109,21 @@
[tableSourceView reloadData];
}
}
- // Reset collation if BINARY was set to 1 since BINARY sets collation to *_bin
+ // Set null field to "do not allow NULL" for auto_increment Extra and reset Extra suggestion list
else if([[aTableColumn identifier] isEqualToString:@"Extra"]) {
if(![[currentRow objectForKey:@"Extra"] isEqualToString:anObject]) {
- if([[[currentRow objectForKey:@"Extra"] uppercaseString] isEqualToString:@"AUTO_INCREMENT"]) {
+
+ isCurrentExtraAutoIncrement = [[[anObject stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] uppercaseString] isEqualToString:@"AUTO_INCREMENT"];
+ if(isCurrentExtraAutoIncrement)
[currentRow setObject:[NSNumber numberWithInteger:0] forKey:@"null"];
- }
+
+ id dataCell = [aTableColumn dataCell];
+ [dataCell removeAllItems];
+ [dataCell addItemsWithObjectValues:extraFieldSuggestions];
+ [dataCell noteNumberOfItemsChanged];
+ [dataCell reloadData];
[tableSourceView reloadData];
+
}
}
// Reset default to "" if field doesn't allow NULL and current default is set to NULL