From 9926b5cdb63b6de0d2766dce0cd4cb3080c3820a Mon Sep 17 00:00:00 2001 From: Bibiko Date: Fri, 16 Oct 2009 08:25:08 +0000 Subject: =?UTF-8?q?=E2=80=A2=20fixed=20issue=20that=20tables=20without=20p?= =?UTF-8?q?rimary=20key=20and=20Pref=20is=20set=20to=20LoadBlobsAsNeeded?= =?UTF-8?q?=20are=20not=20editable=20=E2=80=A2=20fixed=20issue=20if=20user?= =?UTF-8?q?=20tries=20to=20delete=20a=20row=20from=20a=20table=20without?= =?UTF-8?q?=20a=20primary=20key=20and=20Pref=20is=20set=20to=20LoadBlobsAs?= =?UTF-8?q?Needed=20that=20a=20warning=20comes=20up=20and=20the=20table=20?= =?UTF-8?q?data=20keep=20unchanged=20=E2=80=A2=20if=20an=20error=20occurre?= =?UTF-8?q?d=20while=20deleting=20rows=20reload=20the=20table=20data=20aut?= =?UTF-8?q?omatically=20for=20safety=20reasons=20=E2=80=A2=20fixed=20data?= =?UTF-8?q?=20cell=20class=20detection=20for=20returning=20argumentForRow:?= =?UTF-8?q?=20(typo=20after=20changing=20the=20internal=20logic)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Source/TableContent.m | 20 ++++++++++++-------- 1 file 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]; -- cgit v1.2.3