aboutsummaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2009-06-23 10:17:37 +0000
committerBibiko <bibiko@eva.mpg.de>2009-06-23 10:17:37 +0000
commit7b9852ea31e5a070a1f862f42f21c53423a3fb9b (patch)
tree36043a78e78d192db5b077b1f88d83c103978426 /Source
parent68e0fe10f057729f494af0ee7afa681dd7154675 (diff)
downloadsequelpro-7b9852ea31e5a070a1f862f42f21c53423a3fb9b.tar.gz
sequelpro-7b9852ea31e5a070a1f862f42f21c53423a3fb9b.tar.bz2
sequelpro-7b9852ea31e5a070a1f862f42f21c53423a3fb9b.zip
• added SPDataCellFormatter to data cells of the Custom Query table
• in Content Browser send only the first 255 bytes to the cell formatter (makes it a tick faster) • fixed for editing in Content Browser if row contains binary blob data: - use = instead of LIKE operator in UPDATE statement - binary data will converted into X'...' representation
Diffstat (limited to 'Source')
-rw-r--r--Source/CustomQuery.m2
-rw-r--r--Source/TableContent.m59
2 files changed, 35 insertions, 26 deletions
diff --git a/Source/CustomQuery.m b/Source/CustomQuery.m
index 78ee1d80..ac2d08c7 100644
--- a/Source/CustomQuery.m
+++ b/Source/CustomQuery.m
@@ -29,6 +29,7 @@
#import "SPStringAdditions.h"
#import "SPTextViewAdditions.h"
#import "SPArrayAdditions.h"
+#import "SPDataCellFormatter.h"
#import "TableDocument.h"
#import "TablesList.h"
#import "RegexKitLite.h"
@@ -668,6 +669,7 @@
[theCol setResizingMask:NSTableColumnUserResizingMask];
NSTextFieldCell *dataCell = [[[NSTextFieldCell alloc] initTextCell:@""] autorelease];
[dataCell setEditable:YES];
+ [dataCell setFormatter:[[SPDataCellFormatter new] autorelease]];
if ( [prefs boolForKey:@"UseMonospacedFonts"] ) {
[dataCell setFont:[NSFont fontWithName:@"Monaco" size:10]];
} else {
diff --git a/Source/TableContent.m b/Source/TableContent.m
index e6f0d085..06ff12bd 100644
--- a/Source/TableContent.m
+++ b/Source/TableContent.m
@@ -1645,7 +1645,7 @@
id tempValue;
NSMutableString *value = [NSMutableString string];
NSMutableString *argument = [NSMutableString string];
- NSString *columnType;
+ // NSString *columnType;
NSArray *columnNames;
int i,j;
@@ -1701,11 +1701,12 @@
}
if ( [tempValue isKindOfClass:[NSData class]] ) {
- NSString *tmpString = [[NSString alloc] initWithData:tempValue encoding:[mySQLConnection encoding]];
- if (tmpString == nil)
- tmpString = [[NSString alloc] initWithData:tempValue encoding:NSASCIIStringEncoding];
- [value setString:[NSString stringWithString:tmpString]];
- [tmpString release];
+ // NSString *tmpString = [[NSString alloc] initWithData:tempValue encoding:[mySQLConnection encoding]];
+ // if (tmpString == nil)
+ // tmpString = [[NSString alloc] initWithData:tempValue encoding:NSASCIIStringEncoding];
+ // [value setString:[NSString stringWithString:tmpString]];
+ // [tmpString release];
+ [value setString:[NSString stringWithFormat:@"X'%@'", [mySQLConnection prepareBinaryData:tempValue]]];
} else {
[value setString:[tempValue description]];
}
@@ -1714,29 +1715,30 @@
[argument appendString:[NSString stringWithFormat:@"%@ IS NULL", [NSArrayObjectAtIndex(keys, i) backtickQuotedString]]];
} else {
- // Escape special characters (in WHERE statement!)
- for ( j = 0 ; j < [value length] ; j++ ) {
- if ( [value characterAtIndex:j] == '\\' ) {
- [value insertString:@"\\" atIndex:j];
- j++;
+ if (! [tempValue isKindOfClass:[NSData class]] ) {
+ // Escape special characters (in WHERE statement!)
+ for ( j = 0 ; j < [value length] ; j++ ) {
+ if ( [value characterAtIndex:j] == '\\' ) {
+ [value insertString:@"\\" atIndex:j];
+ j++;
+ }
}
- }
- [value setString:[mySQLConnection prepareString:value]];
- for ( j = 0 ; j < [value length] ; j++ ) {
- if ( [value characterAtIndex:j] == '%' ||
- [value characterAtIndex:j] == '_' ) {
- [value insertString:@"\\" atIndex:j];
- j++;
+ [value setString:[mySQLConnection prepareString:value]];
+ for ( j = 0 ; j < [value length] ; j++ ) {
+ if ( [value characterAtIndex:j] == '%' ||
+ [value characterAtIndex:j] == '_' ) {
+ [value insertString:@"\\" atIndex:j];
+ j++;
+ }
}
+ [value setString:[NSString stringWithFormat:@"'%@'", value]];
}
- [value setString:[NSString stringWithFormat:@"'%@'", value]];
-
- columnType = [[tableDataInstance columnWithName:[keys objectAtIndex:i]] objectForKey:@"typegrouping"];
- if ( [columnType isEqualToString:@"integer"] || [columnType isEqualToString:@"float"] || [columnType isEqualToString:@"bit"] ) {
+ // columnType = [[tableDataInstance columnWithName:[keys objectAtIndex:i]] objectForKey:@"typegrouping"];
+ // if ( [columnType isEqualToString:@"integer"] || [columnType isEqualToString:@"float"] || [columnType isEqualToString:@"bit"] ) {
[argument appendString:[NSString stringWithFormat:@"%@ = %@", [NSArrayObjectAtIndex(keys, i) backtickQuotedString], value]];
- } else {
- [argument appendString:[NSString stringWithFormat:@"%@ LIKE %@", [NSArrayObjectAtIndex(keys, i) backtickQuotedString], value]];
- }
+ // } else {
+ // [argument appendString:[NSString stringWithFormat:@"%@ LIKE %@", [NSArrayObjectAtIndex(keys, i) backtickQuotedString], value]];
+ // }
}
}
if ( setLimit )
@@ -1960,7 +1962,12 @@ objectValueForTableColumn:(NSTableColumn *)aTableColumn
if (dataRepresentation == nil)
dataRepresentation = [[NSString alloc] initWithData:theValue encoding:NSASCIIStringEncoding];
if (dataRepresentation == nil) theValue = @"- cannot be displayed -";
- else theValue = [NSString stringWithString:dataRepresentation];
+ else {
+ if([dataRepresentation length]>255)
+ theValue = [[NSString stringWithString:dataRepresentation] substringToIndex:255];
+ else
+ theValue = [NSString stringWithString:dataRepresentation];
+ }
if (dataRepresentation) [dataRepresentation release];
}
return theValue;