aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPCustomQuery.m
diff options
context:
space:
mode:
authorrowanbeentje <rowan@beent.je>2011-05-09 00:35:29 +0000
committerrowanbeentje <rowan@beent.je>2011-05-09 00:35:29 +0000
commit4efbaf34545f7a11baf3b426b8a9b1c25f4f93c7 (patch)
tree24b5a71274b0f8fa3dd2042a535b650fe6e7ce34 /Source/SPCustomQuery.m
parentc6352d1c022fe694bec76dca6caf07eb97e72cdb (diff)
downloadsequelpro-4efbaf34545f7a11baf3b426b8a9b1c25f4f93c7.tar.gz
sequelpro-4efbaf34545f7a11baf3b426b8a9b1c25f4f93c7.tar.bz2
sequelpro-4efbaf34545f7a11baf3b426b8a9b1c25f4f93c7.zip
- When importing CSVs, or editing custom query results, set numeric fields to NULL instead of 0 if an empty string is entered. This matches TableContent behaviour and addresses Issue #1034.
Diffstat (limited to 'Source/SPCustomQuery.m')
-rw-r--r--Source/SPCustomQuery.m13
1 files changed, 9 insertions, 4 deletions
diff --git a/Source/SPCustomQuery.m b/Source/SPCustomQuery.m
index bed5506e..26810323 100644
--- a/Source/SPCustomQuery.m
+++ b/Source/SPCustomQuery.m
@@ -1980,11 +1980,13 @@
if (aTableView == customQueryView) {
NSDictionary *columnDefinition;
+ NSString *columnTypeGroup;
// Retrieve the column defintion
for(id c in cqColumnDefinition) {
if([[c objectForKey:@"datacolumnindex"] isEqualToNumber:[aTableColumn identifier]]) {
columnDefinition = [NSDictionary dictionaryWithDictionary:c];
+ columnTypeGroup = [columnDefinition objectForKey:@"typegrouping"];
break;
}
}
@@ -2018,13 +2020,16 @@
} else {
if ( [[anObject description] isEqualToString:@"CURRENT_TIMESTAMP"] ) {
newObject = @"CURRENT_TIMESTAMP";
- } else if([anObject isEqualToString:[prefs stringForKey:SPNullValue]]) {
+ } else if ([anObject isEqualToString:[prefs stringForKey:SPNullValue]]
+ || (([columnTypeGroup isEqualToString:@"float"] || [columnTypeGroup isEqualToString:@"integer"])
+ && [[anObject description] isEqualToString:@""]))
+ {
newObject = @"NULL";
- } else if ([[columnDefinition objectForKey:@"typegrouping"] isEqualToString:@"geometry"]) {
+ } else if ([columnTypeGroup isEqualToString:@"geometry"]) {
newObject = [(NSString*)anObject getGeomFromTextString];
- } else if ([[columnDefinition objectForKey:@"typegrouping"] isEqualToString:@"bit"]) {
+ } else if ([columnTypeGroup isEqualToString:@"bit"]) {
newObject = [NSString stringWithFormat:@"b'%@'", ((![[anObject description] length] || [[anObject description] isEqualToString:@"0"]) ? @"0" : [anObject description])];
- } else if ([[columnDefinition objectForKey:@"typegrouping"] isEqualToString:@"date"]
+ } else if ([columnTypeGroup isEqualToString:@"date"]
&& [[anObject description] isEqualToString:@"NOW()"]) {
newObject = @"NOW()";
} else {