diff options
Diffstat (limited to 'Source/SPTableContent.m')
-rw-r--r-- | Source/SPTableContent.m | 45 |
1 files changed, 16 insertions, 29 deletions
diff --git a/Source/SPTableContent.m b/Source/SPTableContent.m index b620cf0b..cc5eb6bd 100644 --- a/Source/SPTableContent.m +++ b/Source/SPTableContent.m @@ -2716,43 +2716,27 @@ */ - (NSString *)fieldListForQuery { - NSInteger i; - NSMutableArray *fields = [NSMutableArray array]; - NSArray *columnNames = [tableDataInstance columnNames]; - BOOL hasGeometryFields = NO; + if (([prefs boolForKey:SPLoadBlobsAsNeeded]) && [dataColumns count]) { - if (([prefs boolForKey:SPLoadBlobsAsNeeded]) && ([dataColumns count] > 0)) { + NSMutableArray *fields = [NSMutableArray arrayWithCapacity:[dataColumns count]]; + BOOL tableHasBlobs = NO; + NSString *fieldName; - for (i = 0 ; i < [columnNames count]; i++) - { - if (![tableDataInstance columnIsBlobOrText:[NSArrayObjectAtIndex(dataColumns, i) objectForKey:@"name"]] ) { - if([tableDataInstance columnIsGeometry:[NSArrayObjectAtIndex(dataColumns, i) objectForKey:@"name"]]) - [fields addObject:[NSString stringWithFormat:@"AsText(%@)", [NSArrayObjectAtIndex(columnNames, i) backtickQuotedString]]]; - else - [fields addObject:[NSArrayObjectAtIndex(columnNames, i) backtickQuotedString]]; - } + for (NSDictionary* field in dataColumns) + if (![tableDataInstance columnIsBlobOrText:fieldName = [field objectForKey:@"name"]] ) + [fields addObject:[fieldName backtickQuotedString]]; else { // For blob/text fields, select a null placeholder so the column count is still correct [fields addObject:@"NULL"]; + tableHasBlobs = YES; } - } - return [fields componentsJoinedByString:@","]; - } else { + return (tableHasBlobs) ? [fields componentsJoinedByString:@", "] : @"*"; - for (i = 0 ; i < [columnNames count]; i++) - { - if([tableDataInstance columnIsGeometry:[NSArrayObjectAtIndex(dataColumns, i) objectForKey:@"name"]]) { - [fields addObject:[NSString stringWithFormat:@"AsText(%@)", [NSArrayObjectAtIndex(columnNames, i) backtickQuotedString]]]; - hasGeometryFields = YES; - } - else - [fields addObject:[NSArrayObjectAtIndex(columnNames, i) backtickQuotedString]]; - } - if(hasGeometryFields) - return [fields componentsJoinedByString:@","]; - else - return @"*"; + } + else { + + return @"*"; } } @@ -3416,6 +3400,9 @@ theValue = SPDataStorageObjectAtRowAndColumn(tableValues, rowIndex, columnIndex); } + if([theValue isKindOfClass:[MCPGeometryData class]]) + return [theValue description]; + if ([theValue isNSNull]) return [prefs objectForKey:SPNullValue]; |