diff options
author | Bibiko <bibiko@eva.mpg.de> | 2010-11-01 11:04:01 +0000 |
---|---|---|
committer | Bibiko <bibiko@eva.mpg.de> | 2010-11-01 11:04:01 +0000 |
commit | 7587849d307c6c0a7fa11ddbc2ee48af87ab9087 (patch) | |
tree | 3ae2092799de52002d553baa463a0c04878439f1 /Source/SPTableStructure.m | |
parent | a6325dbb88629e7bc5e170bb23955ebf1910c17b (diff) | |
download | sequelpro-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/SPTableStructure.m')
-rw-r--r-- | Source/SPTableStructure.m | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/Source/SPTableStructure.m b/Source/SPTableStructure.m index 14ae632c..2392c108 100644 --- a/Source/SPTableStructure.m +++ b/Source/SPTableStructure.m @@ -58,7 +58,9 @@ defaultValues = nil; selectedTable = nil; typeSuggestions = nil; + extraFieldSuggestions = nil; currentlyEditingRow = -1; + isCurrentExtraAutoIncrement = NO; fieldValidation = [[SPTableFieldValidation alloc] init]; @@ -80,6 +82,14 @@ [tableSourceView setFont:([prefs boolForKey:SPUseMonospacedFonts]) ? [NSFont fontWithName:SPDefaultMonospacedFontName size:[NSFont smallSystemFontSize]] : [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; [indexesTableView setFont:([prefs boolForKey:SPUseMonospacedFonts]) ? [NSFont fontWithName:SPDefaultMonospacedFontName size:[NSFont smallSystemFontSize]] : [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; + extraFieldSuggestions = [[NSArray arrayWithObjects: + @"None", + @"auto_increment", + @"on update CURRENT_TIMESTAMP", + @"SERIAL DEFAULT VALUE", + nil + ] retain]; + // Note that changing the contents or ordering of this array will affect the implementation of // SPTableFieldValidation. See it's implementation file for more details. typeSuggestions = [[NSArray arrayWithObjects: @@ -326,6 +336,8 @@ nil]; [[self onMainThread] setTableDetails:tableDetails]; + isCurrentExtraAutoIncrement = [tableDataInstance tableHasAutoIncrementField]; + // Send the query finished/work complete notification [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadWithName:@"SMySQLQueryHasBeenPerformed" object:tableDocumentInstance]; @@ -705,6 +717,7 @@ [tableFields replaceObjectAtIndex:currentlyEditingRow withObject:[NSMutableDictionary dictionaryWithDictionary:oldRow]]; } isEditingRow = NO; + isCurrentExtraAutoIncrement = [tableDataInstance tableHasAutoIncrementField]; [tableSourceView reloadData]; currentlyEditingRow = -1; [[tableDocumentInstance parentWindow] makeFirstResponder:tableSourceView]; @@ -1092,7 +1105,9 @@ else if (isEditingNewRow) { [queryString appendFormat:@"\n AFTER %@", [[[tableFields objectAtIndex:(currentlyEditingRow -1)] objectForKey:@"name"] backtickQuotedString]]; } - + + isCurrentExtraAutoIncrement = NO; + // Execute query [mySQLConnection queryString:queryString]; @@ -1543,7 +1558,8 @@ [oldRow release]; [enumFields release]; [typeSuggestions release]; - + [extraFieldSuggestions release]; + [fieldValidation release], fieldValidation = nil; if (defaultValues) [defaultValues release]; |