aboutsummaryrefslogtreecommitdiffstats
path: root/Source/TableContent.m
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2009-10-16 08:25:08 +0000
committerBibiko <bibiko@eva.mpg.de>2009-10-16 08:25:08 +0000
commit9926b5cdb63b6de0d2766dce0cd4cb3080c3820a (patch)
tree07247983d3418553fc75086cfe49608cac7202f9 /Source/TableContent.m
parentc75dd33c1ccb4d64fa413357b9cdbfca36ee2f6a (diff)
downloadsequelpro-9926b5cdb63b6de0d2766dce0cd4cb3080c3820a.tar.gz
sequelpro-9926b5cdb63b6de0d2766dce0cd4cb3080c3820a.tar.bz2
sequelpro-9926b5cdb63b6de0d2766dce0cd4cb3080c3820a.zip
• fixed issue that tables without primary key and Pref is set to LoadBlobsAsNeeded are not editable
• fixed issue if user tries to delete a row from a table without a primary key and Pref is set to LoadBlobsAsNeeded that a warning comes up and the table data keep unchanged • if an error occurred while deleting rows reload the table data automatically for safety reasons • fixed data cell class detection for returning argumentForRow: (typo after changing the internal logic)
Diffstat (limited to 'Source/TableContent.m')
-rw-r--r--Source/TableContent.m20
1 files changed, 12 insertions, 8 deletions
diff --git a/Source/TableContent.m b/Source/TableContent.m
index 70904dbd..ce393faf 100644
--- a/Source/TableContent.m
+++ b/Source/TableContent.m
@@ -1625,7 +1625,7 @@
// If there is no primary key, all the fields are used in the argument.
if ( ![keys count] ) {
[keys setArray:columnNames];
- setLimit = YES;
+ setLimit = YES;
// When the option to not show blob or text options is set, we have a problem - we don't have
// the right values to use in the WHERE statement. Throw an error if this is the case.
@@ -1661,7 +1661,7 @@
if ( [tempValue isKindOfClass:[NSData class]] )
[value setString:[NSString stringWithFormat:@"X'%@'", [mySQLConnection prepareBinaryData:tempValue]]];
else
- [value setString:[NSString stringWithFormat:@"'%@'", [mySQLConnection prepareString:value]]];
+ [value setString:[NSString stringWithFormat:@"'%@'", [mySQLConnection prepareString:tempValue]]];
[argument appendString:[NSString stringWithFormat:@"%@ = %@", [NSArrayObjectAtIndex(keys, i) backtickQuotedString], value]];
}
@@ -1800,6 +1800,8 @@
errors++;
}
} else {
+ if(!reloadAfterRemovingRow)
+ [selectedRows removeIndex:index];
errors++;
}
index = [selectedRows indexGreaterThanIndex:index];
@@ -1817,7 +1819,7 @@
}
// Refresh table content
- if ( reloadAfterRemovingRow ) {
+ if ( errors || reloadAfterRemovingRow ) {
[self loadTableValues];
[tableContentView reloadData];
} else {
@@ -2298,14 +2300,16 @@
* the ON state, or for blob or text fields - in those cases opens a sheet for editing instead and returns NO.
*/
- (BOOL)tableView:(NSTableView *)aTableView shouldEditTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex
-{
-
+{
+
+ // Ensure that row is editable since it could contain "(not loaded)" columns together with
+ // issue that the table has no primary key
+ NSString *wherePart = [NSString stringWithString:[self argumentForRow:[tableContentView selectedRow]]];
+ if ([wherePart length] == 0) return NO;
+
// If the selected cell hasn't been loaded, load it.
if ([NSArrayObjectAtIndex(NSArrayObjectAtIndex(tableValues, rowIndex), [[aTableColumn identifier] intValue]) isSPNotLoaded]) {
- NSString *wherePart = [NSString stringWithString:[self argumentForRow:[tableContentView selectedRow]]];
- if ([wherePart length] == 0) return NO;
-
// Only get the data for the selected column, not all of them
NSString *query = [NSString stringWithFormat:@"SELECT %@ FROM %@ WHERE %@", [[[aTableColumn headerCell] stringValue] backtickQuotedString], [selectedTable backtickQuotedString], wherePart];