diff options
author | rowanbeentje <rowan@beent.je> | 2009-06-22 23:41:56 +0000 |
---|---|---|
committer | rowanbeentje <rowan@beent.je> | 2009-06-22 23:41:56 +0000 |
commit | 5b7810fcc6b6bfd917ce159b1762718c8e8455bf (patch) | |
tree | 7974af2fbfcfa79ef908707704f6abf52218508e | |
parent | 6ea75a39b8053c947fbee5f4b1a7ab4da89120b6 (diff) | |
download | sequelpro-5b7810fcc6b6bfd917ce159b1762718c8e8455bf.tar.gz sequelpro-5b7810fcc6b6bfd917ce159b1762718c8e8455bf.tar.bz2 sequelpro-5b7810fcc6b6bfd917ce159b1762718c8e8455bf.zip |
- Improve r911 (initial Custom Query editability) to allow editing of rows containing NULL values and editing data in tables with names containing backticks
-rw-r--r-- | Source/CustomQuery.m | 26 |
1 files 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 "]; } |