diff options
Diffstat (limited to 'Frameworks/MCPKit/MCPFoundationKit')
-rw-r--r-- | Frameworks/MCPKit/MCPFoundationKit/MCPResult.m | 7 | ||||
-rw-r--r-- | Frameworks/MCPKit/MCPFoundationKit/MCPStreamingResult.m | 48 |
2 files changed, 36 insertions, 19 deletions
diff --git a/Frameworks/MCPKit/MCPFoundationKit/MCPResult.m b/Frameworks/MCPKit/MCPFoundationKit/MCPResult.m index 9d49bda3..d2061fca 100644 --- a/Frameworks/MCPKit/MCPFoundationKit/MCPResult.m +++ b/Frameworks/MCPKit/MCPFoundationKit/MCPResult.m @@ -451,9 +451,12 @@ const OUR_CHARSET our_charsets60[] = case FIELD_TYPE_MEDIUM_BLOB: case FIELD_TYPE_LONG_BLOB: theCurrentObj = [NSData dataWithBytes:theData length:theLengths[i]]; - if (!(theField[i].flags & BINARY_FLAG)) { // It is TEXT and NOT BLOB... + + // It is TEXT and NOT BLOB + if (!(theField[i].flags & BINARY_FLAG)) { theCurrentObj = [self stringWithText:theCurrentObj]; - } // #warning Should check for TEXT (using theField[i].flag BINARY_FLAG) + } + break; case FIELD_TYPE_NULL: diff --git a/Frameworks/MCPKit/MCPFoundationKit/MCPStreamingResult.m b/Frameworks/MCPKit/MCPFoundationKit/MCPStreamingResult.m index 58bd7399..26c9c0fb 100644 --- a/Frameworks/MCPKit/MCPFoundationKit/MCPStreamingResult.m +++ b/Frameworks/MCPKit/MCPFoundationKit/MCPStreamingResult.m @@ -229,36 +229,50 @@ case FIELD_TYPE_SET: case FIELD_TYPE_ENUM: case FIELD_TYPE_NEWDATE: // Don't know what the format for this type is... - cellData = [NSString stringWithCString:theData encoding:mEncoding]; - break; + + // For fields of type BINARY/VARBINARY, return the data. Also add an extra check to make + // sure it's binary data (seems that it's returned as type STRING) to get around a MySQL + // bug (#28214) returning DATE fields with the binary flag set. + if ((fieldDefinitions[i].flags & BINARY_FLAG) && + (fieldDefinitions[i].type == FIELD_TYPE_STRING)) + { + cellData = [NSData dataWithBytes:theData length:fieldLengths[i]]; + } + // For string data, convert to text + else { + cellData = [NSString stringWithCString:theData encoding:mEncoding]; + } + + break; case FIELD_TYPE_BIT: - cellData = [NSString stringWithFormat:@"%u", theData[0]]; - break; + cellData = [NSString stringWithFormat:@"%u", theData[0]]; + break; case FIELD_TYPE_TINY_BLOB: case FIELD_TYPE_BLOB: case FIELD_TYPE_MEDIUM_BLOB: case FIELD_TYPE_LONG_BLOB: - + // For binary data, return the data - if (fieldDefinitions[i].flags & BINARY_FLAG) { - cellData = [NSData dataWithBytes:theData length:fieldLengths[i]]; + if (fieldDefinitions[i].flags & BINARY_FLAG) { + cellData = [NSData dataWithBytes:theData length:fieldLengths[i]]; + } + else { + cellData = [[NSString alloc] initWithBytes:theData length:fieldLengths[i] encoding:mEncoding]; + + if (cellData) [cellData autorelease]; + } - // For string data, convert to text - } else { - cellData = [[NSString alloc] initWithBytes:theData length:fieldLengths[i] encoding:mEncoding]; - if (cellData) [cellData autorelease]; - } - break; + break; case FIELD_TYPE_NULL: - cellData = [NSNull null]; - break; + cellData = [NSNull null]; + break; default: - NSLog(@"in fetchNextRowAsArray : Unknown type : %ld for column %ld, sending back a NSData object", (NSInteger)fieldDefinitions[i].type, (NSInteger)i); - cellData = [NSData dataWithBytes:theData length:fieldLengths[i]]; + NSLog(@"in fetchNextRowAsArray : Unknown type : %ld for column %ld, sending back a NSData object", (NSInteger)fieldDefinitions[i].type, (NSInteger)i); + cellData = [NSData dataWithBytes:theData length:fieldLengths[i]]; break; } |