diff options
author | stuconnolly <stuart02@gmail.com> | 2009-10-21 00:14:44 +0000 |
---|---|---|
committer | stuconnolly <stuart02@gmail.com> | 2009-10-21 00:14:44 +0000 |
commit | da4787ab0f55faf065da34e86c5a7e252911e049 (patch) | |
tree | d04c9e00ee8948d6697441ce0c3c30da6b0c660d /Frameworks | |
parent | 951330376a7b1e85dea0c44825534a4ab598c100 (diff) | |
download | sequelpro-da4787ab0f55faf065da34e86c5a7e252911e049.tar.gz sequelpro-da4787ab0f55faf065da34e86c5a7e252911e049.tar.bz2 sequelpro-da4787ab0f55faf065da34e86c5a7e252911e049.zip |
- Add support for createing fields of type BINARY and VARBINARY in the structure view. Fixes issue #223.
- Fix for correctly displaying data within fields of type BINARY/VARBINARY. Fixes issue #348.
Diffstat (limited to 'Frameworks')
-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; } |