aboutsummaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2010-09-12 18:19:16 +0000
committerBibiko <bibiko@eva.mpg.de>2010-09-12 18:19:16 +0000
commit7240c009185f25fde04ef338b3a2fc0bcd412dfc (patch)
tree625876063f6beb1efd3677b337379c439a796a77 /Source
parentd750c1a18930b0ad1a405760d8df503368ec9502 (diff)
downloadsequelpro-7240c009185f25fde04ef338b3a2fc0bcd412dfc.tar.gz
sequelpro-7240c009185f25fde04ef338b3a2fc0bcd412dfc.tar.bz2
sequelpro-7240c009185f25fde04ef338b3a2fc0bcd412dfc.zip
• added to Structure source table's context menu item: "Show optimized field type" which will come up with a suggested field type calculated by PROCEDURE ANALYSE(0,8192)
Diffstat (limited to 'Source')
-rw-r--r--Source/SPTableStructure.h1
-rw-r--r--Source/SPTableStructure.m49
2 files changed, 50 insertions, 0 deletions
diff --git a/Source/SPTableStructure.h b/Source/SPTableStructure.h
index 6af0a3b3..8a1fa32a 100644
--- a/Source/SPTableStructure.h
+++ b/Source/SPTableStructure.h
@@ -84,6 +84,7 @@
- (IBAction)copyField:(id)sender;
- (IBAction)removeField:(id)sender;
- (IBAction)resetAutoIncrement:(id)sender;
+- (IBAction)showOptimizedFieldType:(id)sender;
// Index sheet methods
- (IBAction)closeSheet:(id)sender;
diff --git a/Source/SPTableStructure.m b/Source/SPTableStructure.m
index 4e95a042..83513b21 100644
--- a/Source/SPTableStructure.m
+++ b/Source/SPTableStructure.m
@@ -399,6 +399,55 @@
}
/**
+ * Show optimized field type for selected field
+ */
+- (IBAction)showOptimizedFieldType:(id)sender
+{
+ MCPResult *theResult = [mySQLConnection queryString:[NSString stringWithFormat:@"SELECT %@ FROM %@ PROCEDURE ANALYSE(0,8192)",
+ [[[tableFields objectAtIndex:[tableSourceView selectedRow]] objectForKey:@"name"] backtickQuotedString],
+ [selectedTable backtickQuotedString]]];
+
+ // Check for errors
+ if ([mySQLConnection queryErrored]) {
+ NSString *mText = NSLocalizedString(@"Error while fetching the optimized field type", @"error while fetching the optimized field type message");
+ if ([mySQLConnection isConnected]) {
+
+ [[NSAlert alertWithMessageText:mText
+ defaultButton:@"OK"
+ alternateButton:nil
+ otherButton:nil
+ informativeTextWithFormat:[NSString stringWithFormat:NSLocalizedString(@"An error occurred while fetching the optimized field type.\n\nMySQL said:%@",@"an error occurred while fetching the optimized field type.\n\nMySQL said:%@"), [mySQLConnection getLastErrorMessage]]]
+ beginSheetModalForWindow:[tableDocumentInstance parentWindow]
+ modalDelegate:self
+ didEndSelector:NULL
+ contextInfo:NULL];
+ }
+
+ return;
+ }
+
+ NSArray *result = [theResult fetch2DResultAsType:MCPTypeDictionary];
+
+ NSString *type = nil;
+
+ if([result count])
+ type = [[result objectAtIndex:0] objectForKey:@"Optimal_fieldtype"];
+ if(!type || ![type length]) {
+ type = NSLocalizedString(@"No optimized field type found.", @"no optimized field type found. message");
+ }
+ [[NSAlert alertWithMessageText:[NSString stringWithFormat:NSLocalizedString(@"Optimized type for field '%@'", @"Optimized type for field %@"), [[tableFields objectAtIndex:[tableSourceView selectedRow]] objectForKey:@"name"]]
+ defaultButton:@"OK"
+ alternateButton:nil
+ otherButton:nil
+ informativeTextWithFormat:type]
+ beginSheetModalForWindow:[tableDocumentInstance parentWindow]
+ modalDelegate:self
+ didEndSelector:NULL
+ contextInfo:NULL];
+
+}
+
+/**
* Copies a field and goes in edit mode for the new field
*/
- (IBAction)copyField:(id)sender