aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPFieldMapperController.m
diff options
context:
space:
mode:
authorrowanbeentje <rowan@beent.je>2012-03-22 23:46:36 +0000
committerrowanbeentje <rowan@beent.je>2012-03-22 23:46:36 +0000
commit760c9b1c387ab827839b77db259537b97a1a8522 (patch)
tree94c086066453448537a07f3855a8303d71dad551 /Source/SPFieldMapperController.m
parent24f89a873caf37947f0447ff870ca4c8d55c453e (diff)
downloadsequelpro-760c9b1c387ab827839b77db259537b97a1a8522.tar.gz
sequelpro-760c9b1c387ab827839b77db259537b97a1a8522.tar.bz2
sequelpro-760c9b1c387ab827839b77db259537b97a1a8522.zip
- Alter the import field mapper controller to support multiple primary keys in its current syntax builder by using the improved getter.
Diffstat (limited to 'Source/SPFieldMapperController.m')
-rw-r--r--Source/SPFieldMapperController.m14
1 files changed, 9 insertions, 5 deletions
diff --git a/Source/SPFieldMapperController.m b/Source/SPFieldMapperController.m
index b406f134..85caa27b 100644
--- a/Source/SPFieldMapperController.m
+++ b/Source/SPFieldMapperController.m
@@ -191,7 +191,7 @@ static NSString *SPTableViewSqlColumnID = @"sql";
showAdvancedView = NO;
targetTableHasPrimaryKey = NO;
- primaryKeyField = nil;
+ primaryKeyFields = nil;
heightOffset = 0;
[advancedReplaceView setHidden:YES];
[advancedUpdateView setHidden:YES];
@@ -224,7 +224,7 @@ static NSString *SPTableViewSqlColumnID = @"sql";
if (fieldMappingGlobalValues) [fieldMappingGlobalValues release];
if (fieldMappingGlobalValuesSQLMarked) [fieldMappingGlobalValuesSQLMarked release];
if (fieldMappingTableDefaultValues) [fieldMappingTableDefaultValues release];
- if (primaryKeyField) [primaryKeyField release];
+ if (primaryKeyFields) [primaryKeyFields release];
if (toBeEditedRowIndexes) [toBeEditedRowIndexes release];
[super dealloc];
}
@@ -565,8 +565,8 @@ static NSString *SPTableViewSqlColumnID = @"sql";
[fieldMappingTableDefaultValues addObject:@"0"];
}
targetTableHasPrimaryKey = YES;
- if (primaryKeyField) [primaryKeyField release];
- primaryKeyField = [[tableDetails objectForKey:@"primarykeyfield"] retain];
+ if (primaryKeyFields) [primaryKeyFields release];
+ primaryKeyFields = [[tableDetails objectForKey:@"primarykeyfield"] retain];
} else {
if([column objectForKey:@"unique"]) {
[type appendFormat:@",%@",@"UNIQUE"];
@@ -1246,7 +1246,11 @@ static NSString *SPTableViewSqlColumnID = @"sql";
[onupdateCheckBox setEnabled:NO];
[onupdateTextView setEditable:YES];
[onupdateTextView setSelectedRange:NSMakeRange(0,[[onupdateTextView string] length])];
- [onupdateTextView insertText:[NSString stringWithFormat:@"%@ = %@", [primaryKeyField backtickQuotedString], [primaryKeyField backtickQuotedString]]];
+ NSMutableArray *queryParts = [NSMutableArray arrayWithCapacity:[primaryKeyFields count]];
+ for (NSString *eachFieldName in primaryKeyFields) {
+ [queryParts addObject:[NSString stringWithFormat:@"%@ = %@", [eachFieldName backtickQuotedString], [eachFieldName backtickQuotedString]]];
+ }
+ [onupdateTextView insertText:[queryParts componentsJoinedByString:@" AND "]];
[onupdateTextView setBackgroundColor:[NSColor lightGrayColor]];
[onupdateTextView setEditable:NO];
} else {