aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Interfaces/English.lproj/DBView.xib14
-rw-r--r--Source/SPExtendedTableInfo.h2
-rw-r--r--Source/SPExtendedTableInfo.m5
-rw-r--r--Source/SPTableContent.m2
-rw-r--r--Source/SPTableData.m1
-rw-r--r--Source/SPTableStructure.h3
-rw-r--r--Source/SPTableStructure.m26
7 files changed, 31 insertions, 22 deletions
diff --git a/Interfaces/English.lproj/DBView.xib b/Interfaces/English.lproj/DBView.xib
index 524e0482..2fd51f54 100644
--- a/Interfaces/English.lproj/DBView.xib
+++ b/Interfaces/English.lproj/DBView.xib
@@ -15857,7 +15857,7 @@ AAEAAQAAAT0AAwAAAAEAAgAAAVIAAwAAAAEAAQAAAVMAAwAAAAIAAQABAAAAAA</bytes>
</object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
- <string key="label">resetAutoIncrementValueWasEdited:</string>
+ <string key="label">tableRowAutoIncrementWasEdited:</string>
<reference key="source" ref="269913528"/>
<reference key="destination" ref="735808692"/>
</object>
@@ -29569,7 +29569,7 @@ AAEAAQAAAT0AAwAAAAEAAgAAAVIAAwAAAAEAAQAAAVMAAwAAAAIAAQABAAAAAA</bytes>
<dictionary class="NSMutableDictionary" key="actions">
<string key="reloadTable:">id</string>
<string key="resetAutoIncrement:">id</string>
- <string key="resetAutoIncrementValueWasEdited:">id</string>
+ <string key="tableRowAutoIncrementWasEdited:">id</string>
<string key="updateTableCollation:">id</string>
<string key="updateTableEncoding:">id</string>
<string key="updateTableType:">id</string>
@@ -29583,8 +29583,8 @@ AAEAAQAAAT0AAwAAAAEAAgAAAVIAAwAAAAEAAQAAAVMAAwAAAAIAAQABAAAAAA</bytes>
<string key="name">resetAutoIncrement:</string>
<string key="candidateClassName">id</string>
</object>
- <object class="IBActionInfo" key="resetAutoIncrementValueWasEdited:">
- <string key="name">resetAutoIncrementValueWasEdited:</string>
+ <object class="IBActionInfo" key="tableRowAutoIncrementWasEdited:">
+ <string key="name">tableRowAutoIncrementWasEdited:</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBActionInfo" key="updateTableCollation:">
@@ -29719,7 +29719,7 @@ AAEAAQAAAT0AAwAAAAEAAgAAAVIAAwAAAAEAAQAAAVMAAwAAAAIAAQABAAAAAA</bytes>
<dictionary class="NSMutableDictionary" key="actions">
<string key="reloadTable:">id</string>
<string key="resetAutoIncrement:">id</string>
- <string key="resetAutoIncrementValueWasEdited:">id</string>
+ <string key="tableRowAutoIncrementWasEdited:">id</string>
<string key="updateTableCollation:">id</string>
<string key="updateTableEncoding:">id</string>
<string key="updateTableType:">id</string>
@@ -29733,8 +29733,8 @@ AAEAAQAAAT0AAwAAAAEAAgAAAVIAAwAAAAEAAQAAAVMAAwAAAAIAAQABAAAAAA</bytes>
<string key="name">resetAutoIncrement:</string>
<string key="candidateClassName">id</string>
</object>
- <object class="IBActionInfo" key="resetAutoIncrementValueWasEdited:">
- <string key="name">resetAutoIncrementValueWasEdited:</string>
+ <object class="IBActionInfo" key="tableRowAutoIncrementWasEdited:">
+ <string key="name">tableRowAutoIncrementWasEdited:</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBActionInfo" key="updateTableCollation:">
diff --git a/Source/SPExtendedTableInfo.h b/Source/SPExtendedTableInfo.h
index 3af8b523..9dd249d9 100644
--- a/Source/SPExtendedTableInfo.h
+++ b/Source/SPExtendedTableInfo.h
@@ -75,7 +75,7 @@
- (IBAction)updateTableEncoding:(id)sender;
- (IBAction)updateTableCollation:(id)sender;
- (IBAction)resetAutoIncrement:(id)sender;
-- (IBAction)resetAutoIncrementValueWasEdited:(id)sender;
+- (IBAction)tableRowAutoIncrementWasEdited:(id)sender;
// Others
- (void)loadTable:(NSString *)table;
diff --git a/Source/SPExtendedTableInfo.m b/Source/SPExtendedTableInfo.m
index 3d27b821..d3b332d0 100644
--- a/Source/SPExtendedTableInfo.m
+++ b/Source/SPExtendedTableInfo.m
@@ -216,10 +216,11 @@ static NSString *SPMySQLCommentField = @"Comment";
}
}
-- (IBAction)resetAutoIncrementValueWasEdited:(id)sender
+- (IBAction)tableRowAutoIncrementWasEdited:(id)sender
{
[tableRowAutoIncrement setEditable:NO];
- [tableSourceInstance setAutoIncrementTo:[[tableRowAutoIncrement stringValue] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]];
+
+ [tableSourceInstance takeAutoIncrementFrom:tableRowAutoIncrement];
}
- (BOOL)control:(NSControl *)control textView:(NSTextView *)textView doCommandBySelector:(SEL)command
diff --git a/Source/SPTableContent.m b/Source/SPTableContent.m
index 308c101b..6988b0f3 100644
--- a/Source/SPTableContent.m
+++ b/Source/SPTableContent.m
@@ -2038,7 +2038,7 @@ static NSString *SPTableFilterSetDefaultOperator = @"SPTableFilterSetDefaultOper
// Reset auto increment if suppression button was ticked
if([[alert suppressionButton] state] == NSOnState) {
- [tableSourceInstance setAutoIncrementTo:@"1"];
+ [tableSourceInstance setAutoIncrementTo:@1];
#ifndef SP_CODA
[prefs setBool:YES forKey:SPResetAutoIncrementAfterDeletionOfAllRows];
#endif
diff --git a/Source/SPTableData.m b/Source/SPTableData.m
index bdd1f1db..d477b444 100644
--- a/Source/SPTableData.m
+++ b/Source/SPTableData.m
@@ -575,6 +575,7 @@
returningInclusively: NO
ignoringQuotedStrings: NO];
if(fieldName == nil || [fieldName length] == 0) {
+#warning NSAlert from background thread! (This whole function needs improvement)
NSBeep();
NSAlert *alert = [[NSAlert alloc] init];
[alert addButtonWithTitle:NSLocalizedString(@"OK", @"OK button")];
diff --git a/Source/SPTableStructure.h b/Source/SPTableStructure.h
index f3d99ea6..781717f8 100644
--- a/Source/SPTableStructure.h
+++ b/Source/SPTableStructure.h
@@ -129,6 +129,7 @@
- (void)removeFieldSheetDidEnd:(NSAlert *)alert returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo;
- (IBAction)resetAutoIncrement:(id)sender;
- (void)resetAutoincrementSheetDidEnd:(NSWindow *)theSheet returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo;
+- (void)takeAutoIncrementFrom:(NSTextField *)field;
- (IBAction)showOptimizedFieldType:(id)sender;
- (IBAction)toggleColumnView:(NSMenuItem *)sender;
- (BOOL)cancelRowEditing;
@@ -142,7 +143,7 @@
- (BOOL)saveRowOnDeselect;
- (BOOL)addRowToDB;
- (void)addRowErrorSheetDidEnd:(NSAlert *)alert returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo;
-- (void)setAutoIncrementTo:(NSString*)valueAsString;
+- (void)setAutoIncrementTo:(NSNumber *)value;
// Accessors
- (NSString *)defaultValueForField:(NSString *)field;
diff --git a/Source/SPTableStructure.m b/Source/SPTableStructure.m
index 992ecdcf..cdc1c8c7 100644
--- a/Source/SPTableStructure.m
+++ b/Source/SPTableStructure.m
@@ -490,7 +490,7 @@ static NSString *SPRemoveFieldAndForeignKey = @"SPRemoveFieldAndForeignKey";
[resetAutoIncrementValue setStringValue:@"1"];
}
else if ([sender tag] == 2) {
- [self setAutoIncrementTo:@"1"];
+ [self setAutoIncrementTo:@1];
}
#endif
}
@@ -505,11 +505,21 @@ static NSString *SPRemoveFieldAndForeignKey = @"SPRemoveFieldAndForeignKey";
[theSheet orderOut:nil];
if (returnCode == NSAlertDefaultReturn) {
- [self setAutoIncrementTo:[[resetAutoIncrementValue stringValue] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]];
+ [self takeAutoIncrementFrom:resetAutoIncrementValue];
}
#endif
}
+- (void)takeAutoIncrementFrom:(NSTextField *)field
+{
+ id obj = [field objectValue];
+ //nil is handled by -setAutoIncrementTo:
+ if(obj && ![obj isKindOfClass:[NSNumber class]]) {
+ [NSException raise:NSInternalInconsistencyException format:@"[$field objectValue] should return NSNumber *, but was %@",[obj class]];
+ }
+ [self setAutoIncrementTo:(NSNumber *)obj];
+}
+
/**
* Process the remove field sheet closing, performing the delete if the user
* confirmed the action.
@@ -600,13 +610,13 @@ static NSString *SPRemoveFieldAndForeignKey = @"SPRemoveFieldAndForeignKey";
*
* @param valueAsString The new auto_increment integer as NSString
*/
-- (void)setAutoIncrementTo:(NSString*)valueAsString
+- (void)setAutoIncrementTo:(NSNumber *)value
{
NSString *selTable = [tablesListInstance tableName];
if (selTable == nil || ![selTable length]) return;
- if (valueAsString == nil || ![valueAsString length]) {
+ if (value == nil) {
// reload data and bail
[tableDataInstance resetAllData];
#ifndef SP_CODA
@@ -616,12 +626,8 @@ static NSString *SPRemoveFieldAndForeignKey = @"SPRemoveFieldAndForeignKey";
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]]];
+ // only int and float types can be AUTO_INCREMENT and right now BIGINT = 64 Bit (<= long long) is the largest type mysql supports
+ [mySQLConnection queryString:[NSString stringWithFormat:@"ALTER TABLE %@ AUTO_INCREMENT = %llu", [selTable backtickQuotedString], [value unsignedLongLongValue]]];
if ([mySQLConnection queryErrored]) {
SPBeginAlertSheet(NSLocalizedString(@"Error", @"error"),