aboutsummaryrefslogtreecommitdiffstats
path: root/Source/TableSource.m
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2009-06-17 10:32:01 +0000
committerBibiko <bibiko@eva.mpg.de>2009-06-17 10:32:01 +0000
commite049666c01af4e7c25ea6b2026935dfa65fd3321 (patch)
treeae7f9ddef960d420756c5f7567f9064c696ab8e6 /Source/TableSource.m
parent59f37e44da3450d37356c87129a3d8592d5c2259 (diff)
downloadsequelpro-e049666c01af4e7c25ea6b2026935dfa65fd3321.tar.gz
sequelpro-e049666c01af4e7c25ea6b2026935dfa65fd3321.tar.bz2
sequelpro-e049666c01af4e7c25ea6b2026935dfa65fd3321.zip
• in r801 the code for inserting a new field containing a PRIMARY KEY after the selected one was commented out
- it's fixed now - improved code to ensure that in this case AFTER ... will be only appended for a new field
Diffstat (limited to 'Source/TableSource.m')
-rw-r--r--Source/TableSource.m28
1 files changed, 19 insertions, 9 deletions
diff --git a/Source/TableSource.m b/Source/TableSource.m
index 0e57234b..0bf67199 100644
--- a/Source/TableSource.m
+++ b/Source/TableSource.m
@@ -242,6 +242,7 @@ reloads the table (performing a new mysql-query)
}
+#pragma mark -
#pragma mark Edit methods
/**
@@ -408,6 +409,7 @@ reloads the table (performing a new mysql-query)
[alert beginSheetModalForWindow:tableWindow modalDelegate:self didEndSelector:@selector(sheetDidEnd:returnCode:contextInfo:) contextInfo:@"removeindex"];
}
+#pragma mark -
#pragma mark Index sheet methods
/*
@@ -451,11 +453,11 @@ opens the indexSheet
//code == 0 -> error while adding index
//code == 1 -> index added with succes OR sheet closed without adding index
if ( code == 0 ) {
- NSBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, nil, nil, nil,
- [NSString stringWithFormat:NSLocalizedString(@"Couldn't add index.\nMySQL said: %@", @"message of panel when index cannot be created"), [mySQLConnection getLastErrorMessage]]);
+ NSBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, nil,
+ nil, nil, [NSString stringWithFormat:NSLocalizedString(@"Couldn't add index.\nMySQL said: %@", @"message of panel when index cannot be created"), [mySQLConnection getLastErrorMessage]]);
} else if ( code == -1 ) {
- NSBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, nil, @selector(closeAlertSheet), nil,
- NSLocalizedString(@"Please insert the columns you want to index.", @"message of panel when no columns are specified to be indexed"));
+ NSBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, nil,
+ @selector(closeAlertSheet), nil, NSLocalizedString(@"Please insert the columns you want to index.", @"message of panel when no columns are specified to be indexed"));
}
}
@@ -499,6 +501,7 @@ closes the keySheet
}
+#pragma mark -
#pragma mark Additional methods
/*
@@ -714,15 +717,17 @@ fetches the result as an array with a dictionary for each row in it
[keySheet orderOut:nil];
if ( code ) {
- if ( [chooseKeyButton indexOfSelectedItem] == 0 ) {
+ if ( [chooseKeyButton indexOfSelectedItem] == 0 ) { // User wants to add PRIMARY KEY
[queryString appendString:@" PRIMARY KEY"];
- //[queryString appendString:[NSString stringWithFormat:@" AFTER %@", [[[tableFields objectAtIndex:(currentlyEditingRow -1)] objectForKey:@"Field"] backtickQuotedString]]];
+ if(isEditingNewRow) // Add AFTER ... only if the user added a new field
+ [queryString appendString:[NSString stringWithFormat:@" AFTER %@", [[[tableFields objectAtIndex:(currentlyEditingRow -1)] objectForKey:@"Field"] backtickQuotedString]]];
} else {
- [queryString appendString:[NSString stringWithFormat:@" AFTER %@", [[[tableFields objectAtIndex:(currentlyEditingRow -1)] objectForKey:@"Field"] backtickQuotedString]]];
+ if(isEditingNewRow) // Add AFTER ... only if the user added a new field
+ [queryString appendString:[NSString stringWithFormat:@" AFTER %@", [[[tableFields objectAtIndex:(currentlyEditingRow -1)] objectForKey:@"Field"] backtickQuotedString]]];
[queryString appendString:[NSString stringWithFormat:@", ADD %@ (%@)", [chooseKeyButton titleOfSelectedItem], [[theRow objectForKey:@"Field"] backtickQuotedString]]];
}
}
- } else if(isEditingNewRow){ // Add AFTER ... only if the user added a new field
+ } else if(isEditingNewRow) { // Add AFTER ... only if the user added a new field
[queryString appendString:[NSString stringWithFormat:@" AFTER %@", [[[tableFields objectAtIndex:(currentlyEditingRow -1)] objectForKey:@"Field"] backtickQuotedString]]];
}
@@ -762,6 +767,7 @@ fetches the result as an array with a dictionary for each row in it
if contextInfo == addrow: remain in edit-mode if user hits OK, otherwise cancel editing
if contextInfo == removefield: removes row from mysql-db if user hits ok
if contextInfo == removeindex: removes index from mysql-db if user hits ok
+ if contextInfo == cannotremovefield: do nothing
*/
if ( [contextInfo isEqualToString:@"addrow"] ) {
@@ -827,7 +833,7 @@ fetches the result as an array with a dictionary for each row in it
}
/**
- * This method is called as part of Key Value Observing which is used to watch for prefernce changes which effect the interface.
+ * This method is called as part of Key Value Observing which is used to watch for preference changes which effect the interface.
*/
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
{
@@ -837,6 +843,7 @@ fetches the result as an array with a dictionary for each row in it
}
}
+#pragma mark -
#pragma mark Getter methods
/*
@@ -901,6 +908,7 @@ returns a dictionary containing enum/set field names as key and possible values
return tempResult;
}
+#pragma mark -
#pragma mark TableView datasource methods
- (int)numberOfRowsInTableView:(NSTableView *)aTableView
@@ -1091,6 +1099,7 @@ would result in a position change.
return YES;
}
+#pragma mark -
#pragma mark TableView delegate methods
- (void)tableViewSelectionDidChange:(NSNotification *)aNotification
@@ -1192,6 +1201,7 @@ traps enter and esc and make/cancel editing without entering next row
[aCell setEnabled:([tablesListInstance tableType] == SP_TABLETYPE_TABLE)];
}
+#pragma mark -
#pragma mark SplitView delegate methods
- (BOOL)splitView:(NSSplitView *)sender canCollapseSubview:(NSView *)subview