diff options
-rw-r--r-- | Source/SPFieldMapperController.h | 2 | ||||
-rw-r--r-- | Source/SPFieldMapperController.m | 14 |
2 files changed, 10 insertions, 6 deletions
diff --git a/Source/SPFieldMapperController.h b/Source/SPFieldMapperController.h index 6fb31b8e..bf88890c 100644 --- a/Source/SPFieldMapperController.h +++ b/Source/SPFieldMapperController.h @@ -125,7 +125,7 @@ BOOL newTableMode; BOOL addGlobalSheetIsOpen; - NSString *primaryKeyField; + NSArray *primaryKeyFields; NSNumber *lastDisabledCSVFieldcolumn; SPMySQLConnection *mySQLConnection; 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 { |