aboutsummaryrefslogtreecommitdiffstats
path: root/Frameworks/MCPKit/MCPFoundationKit/MCPStreamingResult.m
diff options
context:
space:
mode:
authorstuconnolly <stuart02@gmail.com>2009-10-21 00:14:44 +0000
committerstuconnolly <stuart02@gmail.com>2009-10-21 00:14:44 +0000
commitda4787ab0f55faf065da34e86c5a7e252911e049 (patch)
treed04c9e00ee8948d6697441ce0c3c30da6b0c660d /Frameworks/MCPKit/MCPFoundationKit/MCPStreamingResult.m
parent951330376a7b1e85dea0c44825534a4ab598c100 (diff)
downloadsequelpro-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/MCPKit/MCPFoundationKit/MCPStreamingResult.m')
-rw-r--r--Frameworks/MCPKit/MCPFoundationKit/MCPStreamingResult.m48
1 files changed, 31 insertions, 17 deletions
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;
}