diff options
author | rowanbeentje <rowan@beent.je> | 2010-05-04 09:51:06 +0000 |
---|---|---|
committer | rowanbeentje <rowan@beent.je> | 2010-05-04 09:51:06 +0000 |
commit | 6406428538c8daae5c00a8b4080b5c6a03d45be6 (patch) | |
tree | f0332cec0247614bcdd9166f61b856926ff69661 /Source/TableSource.m | |
parent | d7ebbe9b1e17c69a35e7ff05b5fa265e180fcebf (diff) | |
download | sequelpro-6406428538c8daae5c00a8b4080b5c6a03d45be6.tar.gz sequelpro-6406428538c8daae5c00a8b4080b5c6a03d45be6.tar.bz2 sequelpro-6406428538c8daae5c00a8b4080b5c6a03d45be6.zip |
- Merge in r2209release-0.9.8
Diffstat (limited to 'Source/TableSource.m')
-rw-r--r-- | Source/TableSource.m | 33 |
1 files changed, 23 insertions, 10 deletions
diff --git a/Source/TableSource.m b/Source/TableSource.m index 1e3bee8f..27314b03 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,22 +588,37 @@ 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"), NSLocalizedString(@"OK", @"OK button"), 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]; } /** |