aboutsummaryrefslogtreecommitdiffstats
path: root/Source/TableDump.m
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2010-03-22 14:56:05 +0000
committerBibiko <bibiko@eva.mpg.de>2010-03-22 14:56:05 +0000
commitdb2d9565c996e206d82a441cfd8e60627f0eab6d (patch)
treecddd29b39dfaac95062a9412f4a70786f1205171 /Source/TableDump.m
parentf4e32dd6a24793454e0af44a4429cdd9ca737724 (diff)
downloadsequelpro-db2d9565c996e206d82a441cfd8e60627f0eab6d.tar.gz
sequelpro-db2d9565c996e206d82a441cfd8e60627f0eab6d.tar.bz2
sequelpro-db2d9565c996e206d82a441cfd8e60627f0eab6d.zip
• CSV Import
- if a parsed row in the csv file doesn't have the same number of columns as the first row fill the missing columns with SPNotLoaded to allow while importing that these missing data can be replaced by the table column's DEFAULT value - fixed tiny issue for field mapper sheet to display the correct tooltip for default values • SPTableData - ATTENTION: changed the object for returned key 'default': if its value is NULL now it returns a [NSNull null] object - changed instances to handle this [NSNull null] object (must be checked)
Diffstat (limited to 'Source/TableDump.m')
-rw-r--r--Source/TableDump.m17
1 files changed, 15 insertions, 2 deletions
diff --git a/Source/TableDump.m b/Source/TableDump.m
index 12ab01de..a035c750 100644
--- a/Source/TableDump.m
+++ b/Source/TableDump.m
@@ -40,6 +40,7 @@
#import "SPAlertSheets.h"
#import "SPFieldMapperController.h"
#import "SPMainThreadTrampoline.h"
+#import "SPNotLoaded.h"
@implementation TableDump
@@ -1342,6 +1343,10 @@
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 (cellData == [NSNull null]) {
[setString appendString:@"NULL"];
} else {
@@ -1362,6 +1367,10 @@
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 (cellData == [NSNull null]) {
[whereString appendString:@" IS NULL"];
} else {
@@ -1403,6 +1412,10 @@
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 (cellData == [NSNull null]) {
[valueString appendString:@"NULL"];
} else {
@@ -2783,12 +2796,12 @@
if ([column objectForKey:@"default"]) {
// Some MySQL server versions show a default of NULL for NOT NULL columns - don't export those.
- if ([[column objectForKey:@"default"] isEqualToString:@"NULL"]) {
+ if ([column objectForKey:@"default"] == [NSNull null]) {
if ([[column objectForKey:@"null"] integerValue])
[fieldString appendString:@" DEFAULT NULL"];
} else if ([[column objectForKey:@"type"] isEqualToString:@"TIMESTAMP"]
- && [[[column objectForKey:@"default"] uppercaseString] isEqualToString:@"CURRENT_TIMESTAMP"]) {
+ && [column objectForKey:@"default"] != [NSNull null] && [[[column objectForKey:@"default"] uppercaseString] isEqualToString:@"CURRENT_TIMESTAMP"]) {
[fieldString appendString:@" DEFAULT CURRENT_TIMESTAMP"];
} else {
[fieldString appendFormat:@" DEFAULT '%@'", [mySQLConnection prepareString:[column objectForKey:@"default"]]];