aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPTableContent.m
diff options
context:
space:
mode:
authorrowanbeentje <rowan@beent.je>2012-03-24 12:47:23 +0000
committerrowanbeentje <rowan@beent.je>2012-03-24 12:47:23 +0000
commit21df6e7616419aa87513d61d1721394a7da9e16a (patch)
treedd8494d81026dabf9f976e27def63398dce18653 /Source/SPTableContent.m
parent760c9b1c387ab827839b77db259537b97a1a8522 (diff)
downloadsequelpro-21df6e7616419aa87513d61d1721394a7da9e16a.tar.gz
sequelpro-21df6e7616419aa87513d61d1721394a7da9e16a.tar.bz2
sequelpro-21df6e7616419aa87513d61d1721394a7da9e16a.zip
- Fix an exception when attempting to preserve the selection in a table with a primary key with multiple columns of which the first of which is a blob or binary type
- Clean up NSNull comparisons and add comments - Clear the selection when filtering a table, allowing reselection to look a little more consistent
Diffstat (limited to 'Source/SPTableContent.m')
-rw-r--r--Source/SPTableContent.m15
1 files changed, 12 insertions, 3 deletions
diff --git a/Source/SPTableContent.m b/Source/SPTableContent.m
index 948c4eb3..87056e20 100644
--- a/Source/SPTableContent.m
+++ b/Source/SPTableContent.m
@@ -874,10 +874,14 @@
BOOL rowMatches = NO;
for (NSUInteger i = 0; i < tableRowsCount; i++) {
+
+ // For single-column primary keys look up the cell value in the dictionary for a match
if (primaryKeyFieldCount == 1) {
if ([selectionKeysToRestore objectForKey:SPDataStorageObjectAtRowAndColumn(tableValues, i, primaryKeyFieldIndexes[0])]) {
rowMatches = YES;
}
+
+ // For multi-column primary keys, convert all the cells to a string for lookup.
} else {
NSMutableString *lookupString = [[NSMutableString alloc] initWithString:[SPDataStorageObjectAtRowAndColumn(tableValues, i, primaryKeyFieldIndexes[0]) description]];
for (NSUInteger j = 1; j < primaryKeyFieldCount; j++) {
@@ -1649,6 +1653,7 @@
// Update data using the new sort order
previousTableRowsCount = tableRowsCount;
[self setSelectionToRestore:[self selectionDetailsAllowingIndexSelection:NO]];
+ [[tableContentView onMainThread] selectRowIndexes:[NSIndexSet indexSet] byExtendingSelection:NO];
[self loadTableValues];
if ([mySQLConnection queryErrored] && ![mySQLConnection lastQueryWasCancelled]) {
@@ -1870,7 +1875,7 @@
for ( i = 0 ; i < [dataColumns count] ; i++ ) {
column = NSArrayObjectAtIndex(dataColumns, i);
- if ([column objectForKey:@"default"] == nil || [column objectForKey:@"default"] == [NSNull null]) {
+ if ([column objectForKey:@"default"] == nil || [[column objectForKey:@"default"] isNSNull]) {
[newRow addObject:[NSNull null]];
} else if ([[column objectForKey:@"default"] isEqualToString:@""]
&& ![[column objectForKey:@"null"] boolValue]
@@ -3719,10 +3724,14 @@
NSMutableDictionary *selectedRowLookupTable = [NSMutableDictionary dictionaryWithCapacity:indexCount];
NSNumber *trueNumber = [NSNumber numberWithBool:YES];
for (NSUInteger i = 0; i < indexCount; i++) {
+
+ // For single-column primary keys, use the cell value as a dictionary key for fast lookups
if (primaryKeyFieldCount == 1) {
- [selectedRowLookupTable setObject:trueNumber forKey:[SPDataStorageObjectAtRowAndColumn(tableValues, indexBuffer[i], primaryKeyFieldIndexes[0]) description]];
+ [selectedRowLookupTable setObject:trueNumber forKey:SPDataStorageObjectAtRowAndColumn(tableValues, indexBuffer[i], primaryKeyFieldIndexes[0])];
+
+ // For multi-column primary keys, convert all the cell values to a string and use that as the key.
} else {
- NSMutableString *lookupString = [NSMutableString stringWithString:SPDataStorageObjectAtRowAndColumn(tableValues, indexBuffer[i], primaryKeyFieldIndexes[0])];
+ NSMutableString *lookupString = [NSMutableString stringWithString:[SPDataStorageObjectAtRowAndColumn(tableValues, indexBuffer[i], primaryKeyFieldIndexes[0]) description]];
for (NSUInteger j = 1; j < primaryKeyFieldCount; j++) {
[lookupString appendString:SPUniqueSchemaDelimiter];
[lookupString appendString:[SPDataStorageObjectAtRowAndColumn(tableValues, indexBuffer[i], primaryKeyFieldIndexes[j]) description]];