diff options
author | Bibiko <bibiko@eva.mpg.de> | 2010-05-04 09:24:32 +0000 |
---|---|---|
committer | Bibiko <bibiko@eva.mpg.de> | 2010-05-04 09:24:32 +0000 |
commit | 08833c0e96eaf3f306bfaf455e8f77cbffc95d5e (patch) | |
tree | 98724518f7f246a371c5060c479b6a35b1650b43 /Source | |
parent | 2c5d2d7c475c15b5c5a80fc928ae4c3061e5d214 (diff) | |
download | sequelpro-08833c0e96eaf3f306bfaf455e8f77cbffc95d5e.tar.gz sequelpro-08833c0e96eaf3f306bfaf455e8f77cbffc95d5e.tar.bz2 sequelpro-08833c0e96eaf3f306bfaf455e8f77cbffc95d5e.zip |
• fixed formatting issues for entering a new auto_increment value in Table Info tab (this fixes i663)
• improved behaviour if setting of the auto_increment value failed for some reasons
Diffstat (limited to 'Source')
-rw-r--r-- | Source/TableSource.m | 34 |
1 files changed, 24 insertions, 10 deletions
diff --git a/Source/TableSource.m b/Source/TableSource.m index 034a71b9..d6c8fdcf 100644 --- a/Source/TableSource.m +++ b/Source/TableSource.m @@ -577,8 +577,6 @@ closes the keySheet - (void)setAutoIncrementTo:(NSString*)valueAsString { - if(valueAsString == nil || ![valueAsString length]) return; - NSString *selTable = nil; // if selectedTable is nil try to get the name from tablesList @@ -590,7 +588,20 @@ closes the keySheet if(selTable == nil || ![selTable length]) return; - [mySQLConnection queryString:[NSString stringWithFormat:@"ALTER TABLE %@ AUTO_INCREMENT = %@", [selTable backtickQuotedString], valueAsString]]; + if(valueAsString == nil || ![valueAsString length]) { + // reload data and bail + [tableDataInstance resetAllData]; + [extendedTableInfoInstance loadTable:selTable]; + [tableInfoInstance tableChanged:nil]; + return; + } + + NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init]; + [formatter setNumberStyle:NSNumberFormatterDecimalStyle]; + NSNumber *autoIncValue = [formatter numberFromString:valueAsString]; + [formatter release]; + + [mySQLConnection queryString:[NSString stringWithFormat:@"ALTER TABLE %@ AUTO_INCREMENT = %@", [selTable backtickQuotedString], [autoIncValue stringValue]]]; if ([mySQLConnection queryErrored]) { SPBeginAlertSheet(NSLocalizedString(@"Error", @"error"), @@ -598,14 +609,17 @@ closes the keySheet nil, nil, [NSApp mainWindow], nil, nil, nil, nil, [NSString stringWithFormat:NSLocalizedString(@"An error occurred while trying to reset AUTO_INCREMENT of table '%@'.\n\nMySQL said: %@", @"error resetting auto_increment informative message"), selTable, [mySQLConnection getLastErrorMessage]]); - } else { - [tableDataInstance resetStatusData]; - if([[tableDocumentInstance valueForKeyPath:@"tableTabView"] indexOfTabViewItem:[[tableDocumentInstance valueForKeyPath:@"tableTabView"] selectedTabViewItem]] == 3) { - [tableDataInstance resetAllData]; - [extendedTableInfoInstance loadTable:selTable]; - } - [tableInfoInstance tableChanged:nil]; } + + // reload data + [tableDataInstance resetStatusData]; + if([[tableDocumentInstance valueForKeyPath:@"tableTabView"] indexOfTabViewItem:[[tableDocumentInstance valueForKeyPath:@"tableTabView"] selectedTabViewItem]] == 3) { + [tableDataInstance resetAllData]; + [extendedTableInfoInstance loadTable:selTable]; + } + + [tableInfoInstance tableChanged:nil]; + } /** |