aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPFieldMapperController.m
diff options
context:
space:
mode:
Diffstat (limited to 'Source/SPFieldMapperController.m')
-rw-r--r--Source/SPFieldMapperController.m35
1 files changed, 23 insertions, 12 deletions
diff --git a/Source/SPFieldMapperController.m b/Source/SPFieldMapperController.m
index 9bef9d03..8e662b99 100644
--- a/Source/SPFieldMapperController.m
+++ b/Source/SPFieldMapperController.m
@@ -788,7 +788,10 @@ static NSUInteger SPSourceColumnTypeInteger = 1;
if([importFieldNamesHeaderSwitch state] == NSOnState) {
headerRow = NSArrayObjectAtIndex(fieldMappingImportArray, 0);
for (i = 0; i < numberOfImportColumns; i++) {
- [fieldMappingTableColumnNames addObject:NSArrayObjectAtIndex(headerRow, i)];
+ id headerCol = NSArrayObjectAtIndex(headerRow, i);
+ // we don't want a NSNull in the column headers to mess stuff up (issue #2375)
+ if([headerCol isNSNull]) headerCol = [prefs stringForKey:SPNullValue];
+ [fieldMappingTableColumnNames addObject:headerCol];
}
} else {
for (i = 1; i <= numberOfImportColumns; i++) {
@@ -876,11 +879,13 @@ static NSUInteger SPSourceColumnTypeInteger = 1;
BOOL serverGreaterThanVersion4 = ([mySQLConnection serverMajorVersion] >= 5) ? YES : NO;
BOOL importFirstRowAsFieldNames = ([importFieldNamesHeaderSwitch state] == NSOnState);
- NSString *headerName;
+ NSArray *headerRow = NSArrayObjectAtIndex(fieldMappingImportArray, 0);
for (columnCounter = 0; columnCounter < numberOfImportColumns; columnCounter++) {
if (importFirstRowAsFieldNames) {
- headerName = NSArrayObjectAtIndex(NSArrayObjectAtIndex(fieldMappingImportArray, 0), columnCounter);
+ id headerName = NSArrayObjectAtIndex(headerRow, columnCounter);
+ // we don't want a NSNull in the column headers to mess stuff up (issue #2375)
+ if([headerName isNSNull]) headerName = [prefs stringForKey:SPNullValue];
[fieldMappingTableColumnNames addObject:headerName];
} else {
[fieldMappingTableColumnNames addObject:[NSString stringWithFormat:@"col_%ld", (long)(columnCounter + 1)]];
@@ -1043,9 +1048,7 @@ static NSUInteger SPSourceColumnTypeInteger = 1;
NSArray *encodings = [databaseDataInstance getDatabaseCharacterSetEncodings];
NSString *utf8MenuItemTitle = nil;
- if ([encodings count] > 0
- && ([mySQLConnection serverMajorVersion] > 4
- || ([mySQLConnection serverMajorVersion] == 4 && [mySQLConnection serverMinorVersion] >= 1)))
+ if ([encodings count] > 0 && ([mySQLConnection serverVersionIsGreaterThanOrEqualTo:4 minorVersion:1 releaseVersion:0]))
{
[[newTableInfoEncodingPopup menu] addItem:[NSMenuItem separatorItem]];
for (NSDictionary *encoding in encodings) {
@@ -1478,9 +1481,9 @@ static NSUInteger SPSourceColumnTypeInteger = 1;
if (!fieldMappingArray) {
fieldMappingArray = [[NSMutableArray alloc] init];
+ NSArray *currentRowValues = NSArrayObjectAtIndex(fieldMappingImportArray, fieldMappingCurrentRow);
for (i = 0; i < [fieldMappingTableColumnNames count]; i++) {
- if (i < [NSArrayObjectAtIndex(fieldMappingImportArray, fieldMappingCurrentRow) count]
- && ![NSArrayObjectAtIndex(NSArrayObjectAtIndex(fieldMappingImportArray, fieldMappingCurrentRow), i) isNSNull]) {
+ if (i < [currentRowValues count]) {
value = i;
} else {
value = 0;
@@ -1574,7 +1577,9 @@ static NSUInteger SPSourceColumnTypeInteger = 1;
return;
}
for (NSUInteger i = 0; i < [fieldMappingTableColumnNames count]; i++) {
- if (![[fieldMappingTableColumnNames objectAtIndex:i] length] && [doImportKey isEqualToNumber:[fieldMappingOperatorArray objectAtIndex:i]]) {
+ NSString *colName = [fieldMappingTableColumnNames objectAtIndex:i];
+ BOOL shouldImport = [doImportKey isEqualToNumber:[fieldMappingOperatorArray objectAtIndex:i]];
+ if (shouldImport && ![colName length]) {
[importButton setEnabled:NO];
return;
}
@@ -1606,15 +1611,21 @@ static NSUInteger SPSourceColumnTypeInteger = 1;
*/
- (BOOL)validateMenuItem:(NSMenuItem *)menuItem
{
-
NSInteger row = [fieldMapperTableView selectedRow];
// Hide/display Remove New Column menu item
[[[fieldMapperTableView menu] itemAtIndex:3] setHidden:([toBeEditedRowIndexes containsIndex:row]) ? NO : YES];
if (newTableMode && [menuItem action] == @selector(setAllTypesTo:)) {
- NSString *orgTitle = [[menuItem title] substringToIndex:[[menuItem title] rangeOfString:@":"].location];
- [menuItem setTitle:[NSString stringWithFormat:@"%@: %@", orgTitle, [fieldMappingTableTypes objectAtIndex:row]]];
+ if(row > -1) { // row == -1 on empty selection
+ NSString *orgTitle = [[menuItem title] substringToIndex:[[menuItem title] rangeOfString:@":"].location];
+ [menuItem setTitle:[NSString stringWithFormat:@"%@: %@", orgTitle, [fieldMappingTableTypes objectAtIndex:row]]];
+ [menuItem setHidden:NO];
+ }
+ else {
+ [menuItem setHidden:YES];
+ return NO;
+ }
}
else if (!newTableMode && [menuItem action] == @selector(insertNULLValue:)) {
return ([[globalValuesTableView selectedRowIndexes] count] == 1) ? YES : NO;