aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPTableContent.m
diff options
context:
space:
mode:
authorrowanbeentje <rowan@beent.je>2011-07-10 23:54:33 +0000
committerrowanbeentje <rowan@beent.je>2011-07-10 23:54:33 +0000
commit86541d46e1953b1942ddcbdcbe94d5d2caa69f22 (patch)
tree2735eb4bddfa536538a8931964f0e697633cb13e /Source/SPTableContent.m
parent83300fa9c8341de78cb2f5fd2ddc57e778f1a2e7 (diff)
downloadsequelpro-86541d46e1953b1942ddcbdcbe94d5d2caa69f22.tar.gz
sequelpro-86541d46e1953b1942ddcbdcbe94d5d2caa69f22.tar.bz2
sequelpro-86541d46e1953b1942ddcbdcbe94d5d2caa69f22.zip
- Fix exceptions editing non-unique-keyed views or custom query results with some kinds of binary data, fixing http://spbug.com/l/1412 .
- Clean up logic and code
Diffstat (limited to 'Source/SPTableContent.m')
-rw-r--r--Source/SPTableContent.m32
1 files changed, 18 insertions, 14 deletions
diff --git a/Source/SPTableContent.m b/Source/SPTableContent.m
index e88fe9e3..5295bb3d 100644
--- a/Source/SPTableContent.m
+++ b/Source/SPTableContent.m
@@ -1707,25 +1707,29 @@
if ([aValue isKindOfClass:[NSNull class]] || [aValue isNSNull]) {
[fieldIDQueryStr appendFormat:@"%@ IS NULL AND ", [[field objectForKey:@"org_name"] backtickQuotedString]];
} else {
- if ([[field objectForKey:@"typegrouping"] isEqualToString:@"textdata"]) {
- if(includeBlobs) {
- [fieldIDQueryStr appendFormat:@"%@='%@' AND ", [[field objectForKey:@"org_name"] backtickQuotedString], [mySQLConnection prepareString:aValue]];
- }
- }
- else if ([[field objectForKey:@"typegrouping"] isEqualToString:@"blobdata"] || [[field objectForKey:@"type"] isEqualToString:@"BINARY"] || [[field objectForKey:@"type"] isEqualToString:@"VARBINARY"]) {
- if(includeBlobs) {
- [fieldIDQueryStr appendFormat:@"%@=X'%@' AND ", [[field objectForKey:@"org_name"] backtickQuotedString], [mySQLConnection prepareBinaryData:aValue]];
- }
+ NSString *fieldTypeGrouping = [field objectForKey:@"typegrouping"];
+
+ // Skip blob-type fields if requested
+ if (!includeBlobs
+ && ([fieldTypeGrouping isEqualToString:@"textdata"]
+ || [fieldTypeGrouping isEqualToString:@"blobdata"]
+ || [[field objectForKey:@"type"] isEqualToString:@"BINARY"]
+ || [[field objectForKey:@"type"] isEqualToString:@"VARBINARY"]))
+ {
+ continue;
}
- else if ([[field objectForKey:@"typegrouping"] isEqualToString:@"bit"]) {
+
+ // If the field is of type BIT then it needs a binary prefix
+ if ([fieldTypeGrouping isEqualToString:@"bit"]) {
[fieldIDQueryStr appendFormat:@"%@=b'%@' AND ", [[field objectForKey:@"org_name"] backtickQuotedString], [aValue description]];
}
- else if ([[field objectForKey:@"typegrouping"] isEqualToString:@"integer"]) {
- [fieldIDQueryStr appendFormat:@"%@=%@ AND ", [[field objectForKey:@"org_name"] backtickQuotedString], [aValue description]];
- }
- else if ([[field objectForKey:@"typegrouping"] isEqualToString:@"geometry"]) {
+ else if ([fieldTypeGrouping isEqualToString:@"geometry"]) {
[fieldIDQueryStr appendFormat:@"%@=X'%@' AND ", [[field objectForKey:@"org_name"] backtickQuotedString], [mySQLConnection prepareBinaryData:[aValue data]]];
}
+ // BLOB/TEXT data
+ else if ([aValue isKindOfClass:[NSData class]]) {
+ [fieldIDQueryStr appendFormat:@"%@=X'%@' AND ", [[field objectForKey:@"org_name"] backtickQuotedString], [mySQLConnection prepareBinaryData:aValue]];
+ }
else {
[fieldIDQueryStr appendFormat:@"%@='%@' AND ", [[field objectForKey:@"org_name"] backtickQuotedString], [mySQLConnection prepareString:aValue]];
}