From 5b7810fcc6b6bfd917ce159b1762718c8e8455bf Mon Sep 17 00:00:00 2001 From: rowanbeentje Date: Mon, 22 Jun 2009 23:41:56 +0000 Subject: - Improve r911 (initial Custom Query editability) to allow editing of rows containing NULL values and editing data in tables with names containing backticks --- Source/CustomQuery.m | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/Source/CustomQuery.m b/Source/CustomQuery.m index bbbf03da..b0480d0d 100644 --- a/Source/CustomQuery.m +++ b/Source/CustomQuery.m @@ -1271,20 +1271,20 @@ [fieldIDQueryString setString:@"WHERE ("]; for(field in columnsForFieldTableName) { - [fieldIDQueryString appendFormat:@"`%@`=", [field objectForKey:@"org_name"]]; id aValue = [[fullResult objectAtIndex:rowIndex] objectForKey:[field objectForKey:@"name"]]; - if ([aValue isKindOfClass:[NSNull class]]) - [fieldIDQueryString appendString:@"NULL"]; - else if ([[field objectForKey:@"typegrouping"] isEqualToString:@"textdata"]) - [fieldIDQueryString appendFormat:@"'%@'", [mySQLConnection prepareString:aValue]]; - else if ([[field objectForKey:@"typegrouping"] isEqualToString:@"blobdata"]) - [fieldIDQueryString appendFormat:@"X'%@'", [mySQLConnection prepareBinaryData:aValue]]; - else if ([[field objectForKey:@"typegrouping"] isEqualToString:@"integer"]) - [fieldIDQueryString appendFormat:@"%@", [aValue description]]; - else if ([[aValue description] isEqualToString:[prefs stringForKey:@"NullValue"]]) - [fieldIDQueryString appendString:@"NULL"]; - else - [fieldIDQueryString appendFormat:@"'%@'", [mySQLConnection prepareString:aValue]]; + if ([aValue isKindOfClass:[NSNull class]] || [[aValue description] isEqualToString:[prefs stringForKey:@"NullValue"]]) { + [fieldIDQueryString appendFormat:@"%@ IS NULL", [[field objectForKey:@"org_name"] backtickQuotedString]]; + } else { + [fieldIDQueryString appendFormat:@"%@=", [[field objectForKey:@"org_name"] backtickQuotedString]]; + if ([[field objectForKey:@"typegrouping"] isEqualToString:@"textdata"]) + [fieldIDQueryString appendFormat:@"'%@'", [mySQLConnection prepareString:aValue]]; + else if ([[field objectForKey:@"typegrouping"] isEqualToString:@"blobdata"]) + [fieldIDQueryString appendFormat:@"X'%@'", [mySQLConnection prepareBinaryData:aValue]]; + else if ([[field objectForKey:@"typegrouping"] isEqualToString:@"integer"]) + [fieldIDQueryString appendFormat:@"%@", [aValue description]]; + else + [fieldIDQueryString appendFormat:@"'%@'", [mySQLConnection prepareString:aValue]]; + } [fieldIDQueryString appendString:@" AND "]; } -- cgit v1.2.3