aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPTableData.m
diff options
context:
space:
mode:
authorjakob <jakob@eggerapps.at>2010-04-22 09:17:38 +0000
committerjakob <jakob@eggerapps.at>2010-04-22 09:17:38 +0000
commit644ca35f080acd199a69d78dc93526caf5377b3f (patch)
tree3126587561d01d93de514fff59f96c0f606c6dd2 /Source/SPTableData.m
parent6b56ded1a0837cbb3b31765ab86c162eae82231a (diff)
downloadsequelpro-644ca35f080acd199a69d78dc93526caf5377b3f.tar.gz
sequelpro-644ca35f080acd199a69d78dc93526caf5377b3f.tar.bz2
sequelpro-644ca35f080acd199a69d78dc93526caf5377b3f.zip
fix for #642 (deleting more than 3 rows failed on MySQL before 5.0.3)
Diffstat (limited to 'Source/SPTableData.m')
-rw-r--r--Source/SPTableData.m14
1 files changed, 9 insertions, 5 deletions
diff --git a/Source/SPTableData.m b/Source/SPTableData.m
index 207848db..51d490d9 100644
--- a/Source/SPTableData.m
+++ b/Source/SPTableData.m
@@ -1088,25 +1088,29 @@
NSInteger i;
NSMutableArray *keyColumns = [NSMutableArray array];
- r = [mySQLConnection queryString:[NSString stringWithFormat:@"SHOW COLUMNS FROM %@ WHERE `key` = 'PRI'", [selectedTable backtickQuotedString]]];
+ // select all columns that are primary keys
+ // MySQL before 5.0.3 does not support the WHERE syntax
+ r = [mySQLConnection queryString:[NSString stringWithFormat:@"SHOW COLUMNS FROM %@ /*!50003 WHERE `key` = 'PRI'*/", [selectedTable backtickQuotedString]]];
[r setReturnDataAsStrings:YES];
if([r numOfRows] < 1) return nil;
if ([mySQLConnection queryErrored]) {
if ([mySQLConnection isConnected])
- NSRunAlertPanel(@"Error", [NSString stringWithFormat:@"An error occured while retrieving the PRIAMRY KEY data:\n\n%@", [mySQLConnection getLastErrorMessage]], @"OK", nil, nil);
+ NSRunAlertPanel(@"Error", [NSString stringWithFormat:NSLocalizedString(@"An error occured while retrieving the PRIMARY KEY data:\n\n%@",@"message when the query that fetches the primary keys fails"), [mySQLConnection getLastErrorMessage]], @"OK", nil, nil);
return nil;
}
for( i = 0; i < [r numOfRows]; i++ ) {
resultRow = [r fetchRowAsArray];
- [keyColumns addObject:[NSArrayObjectAtIndex(resultRow, 0) description]];
+ // check if the row is indeed a key (for MySQL servers before 5.0.3)
+ if ([[[resultRow objectAtIndex:3] description] isEqualToString:@"PRI"]) {
+ [keyColumns addObject:[[resultRow objectAtIndex:0] description]];
+ }
}
- if([keyColumns count])
- return keyColumns;
+ if([keyColumns count]) return keyColumns;
return nil;
}