aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPCopyTable.m
diff options
context:
space:
mode:
authorAbhi Beckert <abhi@abhibeckert.com>2017-08-04 13:20:12 +1000
committerAbhi Beckert <abhi@abhibeckert.com>2017-08-04 13:20:12 +1000
commitebf7d8b7db4144d304bf2224db19d787d631eda0 (patch)
tree5b1481d8ded07101891b3acce80b385a204f1ef8 /Source/SPCopyTable.m
parentff1db69283f69b8e9dc7fc373db242c37698c7c2 (diff)
parent1cbc8f7ca081a6538a2df484d89723cf441acb3c (diff)
downloadsequelpro-ebf7d8b7db4144d304bf2224db19d787d631eda0.tar.gz
sequelpro-ebf7d8b7db4144d304bf2224db19d787d631eda0.tar.bz2
sequelpro-ebf7d8b7db4144d304bf2224db19d787d631eda0.zip
Merge remote-tracking branch 'sequelpro/master'
Diffstat (limited to 'Source/SPCopyTable.m')
-rw-r--r--Source/SPCopyTable.m37
1 files changed, 28 insertions, 9 deletions
diff --git a/Source/SPCopyTable.m b/Source/SPCopyTable.m
index ed7b1d71..aa77ffbc 100644
--- a/Source/SPCopyTable.m
+++ b/Source/SPCopyTable.m
@@ -184,6 +184,7 @@ static const NSInteger kBlobAsImageFile = 4;
[fm createDirectoryAtPath:tmpBlobFileDirectory withIntermediateDirectories:YES attributes:nil error:nil];
}
+ BOOL hexBlobs = [prefs boolForKey:SPDisplayBinaryDataAsHex];
[selectedRows enumerateIndexesUsingBlock:^(NSUInteger rowIndex, BOOL * _Nonnull stop) {
for (NSUInteger c = 0; c < numColumns; c++ ) {
id cellData = SPDataStorageObjectAtRowAndColumn(tableStorage, rowIndex, columnMappings[c]);
@@ -197,8 +198,12 @@ static const NSInteger kBlobAsImageFile = 4;
[result appendFormat:@"%@\t", NSLocalizedString(@"(not loaded)", @"value shown for hidden blob and text fields")];
else if ([cellData isKindOfClass:[NSData class]]) {
if(withBlobHandling == kBlobInclude) {
- NSString *displayString = [[NSString alloc] initWithData:cellData encoding:[mySQLConnection stringEncoding]];
- if (!displayString) displayString = [[NSString alloc] initWithData:cellData encoding:NSASCIIStringEncoding];
+ NSString *displayString;
+ if (hexBlobs)
+ displayString = [[NSString alloc] initWithFormat:@"0x%@", [cellData dataToHexString]];
+ else
+ displayString = [[NSString alloc] initWithData:cellData encoding:[mySQLConnection stringEncoding]];
+ if (!displayString) displayString = [[NSString alloc] initWithData:cellData encoding:NSISOLatin1StringEncoding];
if (displayString) {
[result appendFormat:@"%@\t", displayString];
[displayString release];
@@ -315,6 +320,7 @@ static const NSInteger kBlobAsImageFile = 4;
[fm createDirectoryAtPath:tmpBlobFileDirectory withIntermediateDirectories:YES attributes:nil error:nil];
}
+ BOOL hexBlobs = [prefs boolForKey:SPDisplayBinaryDataAsHex];
[selectedRows enumerateIndexesUsingBlock:^(NSUInteger rowIndex, BOOL * _Nonnull stop) {
for (NSUInteger c = 0; c < numColumns; c++ ) {
id cellData = SPDataStorageObjectAtRowAndColumn(tableStorage, rowIndex, columnMappings[c]);
@@ -328,8 +334,12 @@ static const NSInteger kBlobAsImageFile = 4;
[result appendFormat:@"\"%@\",", NSLocalizedString(@"(not loaded)", @"value shown for hidden blob and text fields")];
else if ([cellData isKindOfClass:[NSData class]]) {
if(withBlobHandling == kBlobInclude) {
- NSString *displayString = [[NSString alloc] initWithData:cellData encoding:[mySQLConnection stringEncoding]];
- if (!displayString) displayString = [[NSString alloc] initWithData:cellData encoding:NSASCIIStringEncoding];
+ NSString *displayString;
+ if (hexBlobs)
+ displayString = [[NSString alloc] initWithFormat:@"0x%@", [cellData dataToHexString]];
+ else
+ displayString = [[NSString alloc] initWithData:cellData encoding:[mySQLConnection stringEncoding]];
+ if (!displayString) displayString = [[NSString alloc] initWithData:cellData encoding:NSISOLatin1StringEncoding];
if (displayString) {
[result appendFormat:@"\"%@\",", displayString];
[displayString release];
@@ -620,6 +630,7 @@ static const NSInteger kBlobAsImageFile = 4;
Class nsDataClass = [NSData class];
Class spmysqlGeometryData = [SPMySQLGeometryData class];
NSStringEncoding connectionEncoding = [mySQLConnection stringEncoding];
+ BOOL hexBlobs = [prefs boolForKey:SPDisplayBinaryDataAsHex];
[selectedRows enumerateIndexesUsingBlock:^(NSUInteger rowIndex, BOOL * _Nonnull stop) {
for (NSUInteger c = 0; c < numColumns; c++ ) {
id cellData = SPDataStorageObjectAtRowAndColumn(tableStorage, rowIndex, columnMappings[c]);
@@ -632,10 +643,15 @@ static const NSInteger kBlobAsImageFile = 4;
else if ([cellData isSPNotLoaded])
[result appendFormat:@"%@\t", NSLocalizedString(@"(not loaded)", @"value shown for hidden blob and text fields")];
else if ([cellData isKindOfClass:nsDataClass]) {
- NSString *displayString = [[NSString alloc] initWithData:cellData encoding:connectionEncoding];
- if (!displayString) displayString = [[NSString alloc] initWithData:cellData encoding:NSASCIIStringEncoding];
+ NSString *displayString;
+ if (hexBlobs)
+ displayString = [[NSString alloc] initWithFormat:@"0x%@", [cellData dataToHexString]];
+ else
+ displayString = [[NSString alloc] initWithData:cellData encoding:connectionEncoding];
+ if (!displayString) displayString = [[NSString alloc] initWithData:cellData encoding:NSISOLatin1StringEncoding];
if (displayString) {
[result appendString:displayString];
+ [result appendString:@"\t"];
[displayString release];
}
}
@@ -749,7 +765,6 @@ static const NSInteger kBlobAsImageFile = 4;
- (NSUInteger)autodetectWidthForColumnDefinition:(NSDictionary *)columnDefinition maxRows:(NSUInteger)rowsToCheck
{
CGFloat columnBaseWidth;
- id contentString;
NSUInteger cellWidth, maxCellWidth, i;
NSRange linebreakRange;
double rowStep;
@@ -762,6 +777,7 @@ static const NSInteger kBlobAsImageFile = 4;
NSUInteger columnIndex = (NSUInteger)[[columnDefinition objectForKey:@"datacolumnindex"] integerValue];
NSDictionary *stringAttributes = @{NSFontAttributeName : tableFont};
Class spmysqlGeometryData = [SPMySQLGeometryData class];
+ BOOL hexBlobs = [prefs boolForKey:SPDisplayBinaryDataAsHex];
// Check the number of rows available to check, sampling every n rows
if ([tableStorage count] < rowsToCheck)
@@ -779,7 +795,7 @@ static const NSInteger kBlobAsImageFile = 4;
for (i = 0; i < rowsToCheck; i += rowStep) {
// Retrieve part of the cell's content to get widths, topping out at a maximum length
- contentString = SPDataStoragePreviewAtRowAndColumn(tableStorage, i, columnIndex, 500);
+ id contentString = SPDataStoragePreviewAtRowAndColumn(tableStorage, i, columnIndex, 500);
// If the cell hasn't loaded yet, skip processing
if (!contentString)
@@ -801,7 +817,10 @@ static const NSInteger kBlobAsImageFile = 4;
// Otherwise, ensure the cell is represented as a short string
if ([contentString isKindOfClass:[NSData class]]) {
- contentString = [contentString shortStringRepresentationUsingEncoding:[mySQLConnection stringEncoding]];
+ if (hexBlobs)
+ contentString = [[NSString alloc] initWithFormat:@"0x%@", [(NSData *)contentString dataToHexString]];
+ else
+ contentString = [contentString shortStringRepresentationUsingEncoding:[mySQLConnection stringEncoding]];
} else if ([(NSString *)contentString length] > 500) {
contentString = [contentString substringToIndex:500];
}