aboutsummaryrefslogtreecommitdiffstats
path: root/Source/TableDump.m
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2010-03-22 18:32:44 +0000
committerBibiko <bibiko@eva.mpg.de>2010-03-22 18:32:44 +0000
commit6728ccd128a5320256ac51c0a617f0c76b331ea7 (patch)
tree2fb01ae702a56ba3c3cdee10e421abb8ff98eda8 /Source/TableDump.m
parent3934c544c9b2e2f77227864ad9c91bd8bb1077fe (diff)
downloadsequelpro-6728ccd128a5320256ac51c0a617f0c76b331ea7.tar.gz
sequelpro-6728ccd128a5320256ac51c0a617f0c76b331ea7.tar.bz2
sequelpro-6728ccd128a5320256ac51c0a617f0c76b331ea7.zip
• CSV Import Field Mapper
- added the chance to mark a global value as SQL statement in the sheet to allow to use a calculated value like LENGTH(`foo`) or NOW() while inserting/replacing/updating • added ^⌥⌘N short-cut Navigator (still hidden)
Diffstat (limited to 'Source/TableDump.m')
-rw-r--r--Source/TableDump.m81
1 files changed, 44 insertions, 37 deletions
diff --git a/Source/TableDump.m b/Source/TableDump.m
index a035c750..db26db5a 100644
--- a/Source/TableDump.m
+++ b/Source/TableDump.m
@@ -1338,21 +1338,23 @@
[setString appendString:@"="];
// Append the data
// - check for global values
- if(fieldMappingArrayHasGlobalVariables && mapColumn >= numberOfImportDataColumns)
- cellData = NSArrayObjectAtIndex(fieldMappingGlobalValueArray, mapColumn);
- else
+ if(fieldMappingArrayHasGlobalVariables && mapColumn >= numberOfImportDataColumns) {
+ // Global variables are coming wrapped in ' ' if there're not marked as SQL
+ [setString appendString:NSArrayObjectAtIndex(fieldMappingGlobalValueArray, mapColumn)];
+ } else {
cellData = NSArrayObjectAtIndex(csvRowArray, mapColumn);
- // If import column isn't specified import the table column default value
- if ([cellData isSPNotLoaded])
- cellData = NSArrayObjectAtIndex(fieldMappingTableDefaultValues, i);
+ // If import column isn't specified import the table column default value
+ if ([cellData isSPNotLoaded])
+ cellData = NSArrayObjectAtIndex(fieldMappingTableDefaultValues, i);
- if (cellData == [NSNull null]) {
- [setString appendString:@"NULL"];
- } else {
- [setString appendString:@"'"];
- [setString appendString:[mySQLConnection prepareString:cellData]];
- [setString appendString:@"'"];
+ if (cellData == [NSNull null]) {
+ [setString appendString:@"NULL"];
+ } else {
+ [setString appendString:@"'"];
+ [setString appendString:[mySQLConnection prepareString:cellData]];
+ [setString appendString:@"'"];
+ }
}
}
// WHERE clause
@@ -1362,22 +1364,25 @@
[whereString appendString:[NSArrayObjectAtIndex(fieldMappingTableColumnNames, i) backtickQuotedString]];
// Append the data
// - check for global values
- if(fieldMappingArrayHasGlobalVariables && mapColumn >= numberOfImportDataColumns)
- cellData = NSArrayObjectAtIndex(fieldMappingGlobalValueArray, mapColumn);
- else
+ if(fieldMappingArrayHasGlobalVariables && mapColumn >= numberOfImportDataColumns) {
+ // Global variables are coming wrapped in ' ' if there're not marked as SQL
+ [whereString appendString:@"="];
+ [whereString appendString:NSArrayObjectAtIndex(fieldMappingGlobalValueArray, mapColumn)];
+ } else {
cellData = NSArrayObjectAtIndex(csvRowArray, mapColumn);
- // If import column isn't specified import the table column default value
- if ([cellData isSPNotLoaded])
- cellData = NSArrayObjectAtIndex(fieldMappingTableDefaultValues, i);
+ // If import column isn't specified import the table column default value
+ if ([cellData isSPNotLoaded])
+ cellData = NSArrayObjectAtIndex(fieldMappingTableDefaultValues, i);
- if (cellData == [NSNull null]) {
- [whereString appendString:@" IS NULL"];
- } else {
- [whereString appendString:@"="];
- [whereString appendString:@"'"];
- [whereString appendString:[mySQLConnection prepareString:cellData]];
- [whereString appendString:@"'"];
+ if (cellData == [NSNull null]) {
+ [whereString appendString:@" IS NULL"];
+ } else {
+ [whereString appendString:@"="];
+ [whereString appendString:@"'"];
+ [whereString appendString:[mySQLConnection prepareString:cellData]];
+ [whereString appendString:@"'"];
+ }
}
}
}
@@ -1407,21 +1412,23 @@
// Append the data
// - check for global values
- if(fieldMappingArrayHasGlobalVariables && mapColumn >= numberOfImportDataColumns)
- cellData = NSArrayObjectAtIndex(fieldMappingGlobalValueArray, mapColumn);
- else
+ if(fieldMappingArrayHasGlobalVariables && mapColumn >= numberOfImportDataColumns) {
+ // Global variables are coming wrapped in ' ' if there're not marked as SQL
+ [valueString appendString:NSArrayObjectAtIndex(fieldMappingGlobalValueArray, mapColumn)];
+ } else {
cellData = NSArrayObjectAtIndex(csvRowArray, mapColumn);
- // If import column isn't specified import the table column default value
- if ([cellData isSPNotLoaded])
- cellData = NSArrayObjectAtIndex(fieldMappingTableDefaultValues, i);
+ // If import column isn't specified import the table column default value
+ if ([cellData isSPNotLoaded])
+ cellData = NSArrayObjectAtIndex(fieldMappingTableDefaultValues, i);
- if (cellData == [NSNull null]) {
- [valueString appendString:@"NULL"];
- } else {
- [valueString appendString:@"'"];
- [valueString appendString:[mySQLConnection prepareString:cellData]];
- [valueString appendString:@"'"];
+ if (cellData == [NSNull null]) {
+ [valueString appendString:@"NULL"];
+ } else {
+ [valueString appendString:@"'"];
+ [valueString appendString:[mySQLConnection prepareString:cellData]];
+ [valueString appendString:@"'"];
+ }
}
}