aboutsummaryrefslogtreecommitdiffstats
path: root/Source/TableContent.m
diff options
context:
space:
mode:
Diffstat (limited to 'Source/TableContent.m')
-rw-r--r--Source/TableContent.m25
1 files changed, 15 insertions, 10 deletions
diff --git a/Source/TableContent.m b/Source/TableContent.m
index 734b4d96..19f77db4 100644
--- a/Source/TableContent.m
+++ b/Source/TableContent.m
@@ -1869,21 +1869,26 @@
[deleteQuery appendString:@"("];
for(NSString *primaryKeyFieldName in primaryKeyFieldNames) {
- [deleteQuery appendFormat:@"%@=", [primaryKeyFieldName backtickQuotedString]];
id keyValue = [NSArrayObjectAtIndex(tableValues, index) objectAtIndex:[[[tableDataInstance columnWithName:primaryKeyFieldName] objectForKey:@"datacolumnindex"] intValue]];
- if([keyValue isKindOfClass:[NSData class]])
- [deleteQuery appendString:[NSString stringWithFormat:@"X'%@'", [mySQLConnection prepareBinaryData:keyValue]]];
- else
- [deleteQuery appendString:[NSString stringWithFormat:@"'%@'", [keyValue description]]];
-
- [deleteQuery appendString:@" AND "];
+ [deleteQuery appendString:[primaryKeyFieldName backtickQuotedString]];
+ if ([keyValue isKindOfClass:[NSData class]]) {
+ [deleteQuery appendString:@"=X'"];
+ [deleteQuery appendString:[mySQLConnection prepareBinaryData:keyValue]];
+ } else {
+ [deleteQuery appendString:@"='"];
+ [deleteQuery appendString:[mySQLConnection prepareString:[keyValue description]]];
+ }
+ [deleteQuery appendString:@"' AND "];
}
- [deleteQuery setString:[NSString stringWithFormat:@"%@)", [deleteQuery substringToIndex:([deleteQuery length]-5)]]];
+
+ // Remove the trailing AND and add the closing bracket
+ [deleteQuery deleteCharactersInRange:NSMakeRange([deleteQuery length]-5, 5)];
+ [deleteQuery appendString:@")"];
- // Split deletion query into 256k chunks
- if([deleteQuery length] > 256000) {
+ // Split deletion query into 64k chunks
+ if([deleteQuery length] > 64000) {
[mySQLConnection queryString:deleteQuery];
// Remember affected rows for error checking
affectedRows += [mySQLConnection affectedRows];