diff options
author | Bibiko <bibiko@eva.mpg.de> | 2010-03-04 14:17:35 +0000 |
---|---|---|
committer | Bibiko <bibiko@eva.mpg.de> | 2010-03-04 14:17:35 +0000 |
commit | d63dff9e7b9f88799b5fa753c8a3510404aa17b8 (patch) | |
tree | da8df9d549147a108f3d2095b0a8b8514f1f0018 /Source/SPFieldMapperController.m | |
parent | e9d08a697eaf44b1c620706d55dd619f77d33af1 (diff) | |
download | sequelpro-d63dff9e7b9f88799b5fa753c8a3510404aa17b8.tar.gz sequelpro-d63dff9e7b9f88799b5fa753c8a3510404aa17b8.tar.bz2 sequelpro-d63dff9e7b9f88799b5fa753c8a3510404aa17b8.zip |
• CSV Import Field Mapper
- added UPDATE method which allows to configure an import statement à la:
UPDATE t1 SET col1=foo1, col2=foo2 WHERE col3=baz1 AND col4=baz2
- Insert remaining rows (which are not matched) isn't implemented yet
- note: further tests are needed to ensure it works as expected
Diffstat (limited to 'Source/SPFieldMapperController.m')
-rw-r--r-- | Source/SPFieldMapperController.m | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/Source/SPFieldMapperController.m b/Source/SPFieldMapperController.m index 8f13b6bb..e6fafe1b 100644 --- a/Source/SPFieldMapperController.m +++ b/Source/SPFieldMapperController.m @@ -162,7 +162,7 @@ - (NSString*)selectedTableTarget { - return [tableTargetPopup titleOfSelectedItem]; + return ([tableTargetPopup titleOfSelectedItem] == nil) ? @"" : [tableTargetPopup titleOfSelectedItem]; } - (NSArray*)fieldMapperOperator @@ -172,7 +172,7 @@ - (NSString*)selectedImportMethod { - return [importMethodPopup titleOfSelectedItem]; + return ([importMethodPopup titleOfSelectedItem] == nil) ? @"" : [importMethodPopup titleOfSelectedItem]; } - (NSArray*)fieldMappingArray @@ -213,6 +213,9 @@ ([delayedCheckBox state] == NSOnState) ? @"DELAYED " : @"" ]; } + else if([[importMethodPopup titleOfSelectedItem] isEqualToString:@"UPDATE"]) { + return [NSString stringWithFormat:@"UPDATE %@ SET ", [[self selectedTableTarget] backtickQuotedString]]; + } return @""; } @@ -330,6 +333,7 @@ } else { [advancedButton setEnabled:NO]; [addRemainingDataSwitch setHidden:NO]; + [addRemainingDataSwitch setEnabled:NO]; // TODO HansJB } [self validateImportButton]; @@ -383,7 +387,7 @@ [fieldMapperTableView reloadData]; - [recordCountLabel setStringValue:[NSString stringWithFormat:@"%ld of %@%lu records", (long)(fieldMappingCurrentRow+1), fieldMappingImportArrayIsPreview?@"first ":@"", (unsigned long)[fieldMappingImportArray count]]]; + [recordCountLabel setStringValue:[NSString stringWithFormat:NSLocalizedString(@"%ld of %@%lu records", @"%ld of %@%lu records"), (long)(fieldMappingCurrentRow+1), fieldMappingImportArrayIsPreview?@"first ":@"", (unsigned long)[fieldMappingImportArray count]]]; // enable/disable buttons [rowDownButton setEnabled:(fieldMappingCurrentRow != 0)]; @@ -691,7 +695,6 @@ break; } } - enableImportButton = NO; // TODO HansJB WIP } [importButton setEnabled:enableImportButton]; } @@ -897,8 +900,8 @@ [fieldMappingArray replaceObjectAtIndex:rowIndex withObject:anObject]; - // If user _changed_ the csv file column set the operator to doImport - if([(NSNumber*)anObject integerValue] > -1) + // If user _changed_ the csv file column set the operator to doImport if not set to = + if([(NSNumber*)anObject integerValue] > -1 && NSArrayObjectAtIndex(fieldMappingOperatorArray, rowIndex) != isEqual) [fieldMappingOperatorArray replaceObjectAtIndex:rowIndex withObject:doImport]; [self validateImportButton]; |