From be97d12d4f5df97b268bd017f124d932f8d5d4a9 Mon Sep 17 00:00:00 2001 From: Bibiko Date: Mon, 25 Oct 2010 12:45:18 +0000 Subject: =?UTF-8?q?=E2=80=A2=20improved=20the=20TableStructure=20handling?= =?UTF-8?q?=20of=20GEOMETRY=20fields=20and=20their=20validations=20against?= =?UTF-8?q?=20non-valid=20WKT=20notations=20-=20return=20NULL=20if=20no=20?= =?UTF-8?q?header?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Source/SPStringAdditions.m | 2 +- Source/SPTableContent.m | 6 +++--- Source/SPTableStructure.m | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) (limited to 'Source') diff --git a/Source/SPStringAdditions.m b/Source/SPStringAdditions.m index ea603cbc..847b4dbc 100644 --- a/Source/SPStringAdditions.m +++ b/Source/SPStringAdditions.m @@ -382,7 +382,7 @@ NSString *geomStr = [self stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; - if(![self rangeOfString:@")"].length || [self length] < 5) return @""; + if(![self rangeOfString:@")"].length || [self length] < 5) return @"NULL"; // No SRID if([geomStr hasSuffix:@")"]) diff --git a/Source/SPTableContent.m b/Source/SPTableContent.m index fe586e8a..c1c28c61 100644 --- a/Source/SPTableContent.m +++ b/Source/SPTableContent.m @@ -2389,9 +2389,6 @@ { [rowValue setString:@"CURRENT_TIMESTAMP"]; - } else if ( [[NSArrayObjectAtIndex(dataColumns, i) objectForKey:@"typegrouping"] isEqualToString:@"geometry"] ) { - [rowValue setString:([rowObject isKindOfClass:[MCPGeometryData class]]) ? [[rowObject wktString] getGeomFromTextString] : [(NSString*)rowObject getGeomFromTextString]]; - // Convert the object to a string (here we can add special treatment for date-, number- and data-fields) } else if ( [rowObject isNSNull] || ([rowObject isMemberOfClass:[NSString class]] && [[rowObject description] isEqualToString:@""]) ) { @@ -2399,6 +2396,9 @@ // problem: when a number isn't set, sequel-pro enters 0 // -> second if argument isn't necessary! [rowValue setString:@"NULL"]; + } else if ( [[NSArrayObjectAtIndex(dataColumns, i) objectForKey:@"typegrouping"] isEqualToString:@"geometry"] ) { + [rowValue setString:([rowObject isKindOfClass:[MCPGeometryData class]]) ? [[rowObject wktString] getGeomFromTextString] : [(NSString*)rowObject getGeomFromTextString]]; + // Convert the object to a string (here we can add special treatment for date-, number- and data-fields) } else { // I don't believe any of these class matches are ever met at present. diff --git a/Source/SPTableStructure.m b/Source/SPTableStructure.m index e6afab2d..5c5a400a 100644 --- a/Source/SPTableStructure.m +++ b/Source/SPTableStructure.m @@ -1546,7 +1546,7 @@ returns a dictionary containing enum/set field names as key and possible values if(anObject && [(NSString*)anObject length] && ![(NSString*)anObject hasPrefix:@"--"]) { [currentRow setObject:[(NSString*)anObject uppercaseString] forKey:@"type"]; // If type is BLOB or TEXT reset DEFAULT since these field types don't allow a default - if([[currentRow objectForKey:@"type"] hasSuffix:@"TEXT"] || [[currentRow objectForKey:@"type"] hasSuffix:@"BLOB"]) { + if([[currentRow objectForKey:@"type"] hasSuffix:@"TEXT"] || [[currentRow objectForKey:@"type"] hasSuffix:@"BLOB"] || [self _isFieldTypeGeometry:[currentRow objectForKey:@"type"]]) { [currentRow setObject:@"" forKey:@"default"]; [currentRow setObject:@"" forKey:@"length"]; } @@ -1897,9 +1897,9 @@ would result in a position change. else if([[aTableColumn identifier] isEqualToString:@"binary"]) { [aCell setEnabled:([self _isFieldTypeAllowBinary:theRowType])]; } - // TEXT or BLOB fields don't allow a DEFAULT + // TEXT, BLOB, and GEOMETRY fields don't allow a DEFAULT else if([[aTableColumn identifier] isEqualToString:@"default"]) { - [aCell setEnabled:([theRowType hasSuffix:@"TEXT"] || [theRowType hasSuffix:@"BLOB"]) ? NO : YES]; + [aCell setEnabled:([theRowType hasSuffix:@"TEXT"] || [theRowType hasSuffix:@"BLOB"] || [self _isFieldTypeGeometry:theRowType]) ? NO : YES]; } // Check allow NULL else if([[aTableColumn identifier] isEqualToString:@"null"]) { -- cgit v1.2.3