aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPDatabaseDocument.m
diff options
context:
space:
mode:
authorrowanbeentje <rowan@beent.je>2012-03-22 01:18:18 +0000
committerrowanbeentje <rowan@beent.je>2012-03-22 01:18:18 +0000
commit24f89a873caf37947f0447ff870ca4c8d55c453e (patch)
tree22162a0e1eead7190e316c384ff8c6c1b98661b3 /Source/SPDatabaseDocument.m
parent3916b4227d1e02942504e13a2d36b3e6f57670bb (diff)
downloadsequelpro-24f89a873caf37947f0447ff870ca4c8d55c453e.tar.gz
sequelpro-24f89a873caf37947f0447ff870ca4c8d55c453e.tar.bz2
sequelpro-24f89a873caf37947f0447ff870ca4c8d55c453e.zip
- Rework SPTableData PRIMARY KEY and UNIQUE KEY parsing to use SPSQLParser instead of regexes
- Support multiple primary keys in the SPTableData parse - If possible, use primary keys to preserve table content selection instead of row indexes - Improve SPTableData primary keys method to use cached value instead of using another query - Preserve selection when filtering tables if appropriate
Diffstat (limited to 'Source/SPDatabaseDocument.m')
-rw-r--r--Source/SPDatabaseDocument.m23
1 files changed, 5 insertions, 18 deletions
diff --git a/Source/SPDatabaseDocument.m b/Source/SPDatabaseDocument.m
index 7fd93c1b..529b05f5 100644
--- a/Source/SPDatabaseDocument.m
+++ b/Source/SPDatabaseDocument.m
@@ -4297,16 +4297,9 @@ static NSString *SPCreateSyntx = @"SPCreateSyntax";
if ([tableContentInstance filterSettings])
[sessionState setObject:[tableContentInstance filterSettings] forKey:@"contentFilter"];
- NSIndexSet *contentSelectedIndexSet = [tableContentInstance selectedRowIndexes];
- if (contentSelectedIndexSet && [contentSelectedIndexSet count]) {
- NSMutableArray *indices = [NSMutableArray array];
- NSUInteger indexBuffer[[contentSelectedIndexSet count]];
- NSUInteger limit = [contentSelectedIndexSet getIndexes:indexBuffer maxCount:[contentSelectedIndexSet count] inIndexRange:NULL];
- NSUInteger idx;
- for (idx = 0; idx < limit; idx++) {
- [indices addObject:[NSNumber numberWithInteger:indexBuffer[idx]]];
- }
- [sessionState setObject:indices forKey:@"contentSelectedIndexSet"];
+ NSDictionary *contentSelectedRows = [tableContentInstance selectionDetailsAllowingIndexSelection:YES];
+ if (contentSelectedRows) {
+ [sessionState setObject:contentSelectedRows forKey:@"contentSelection"];
}
}
@@ -4734,14 +4727,8 @@ static NSString *SPCreateSyntx = @"SPCreateSyntax";
[tablesListInstance selectTableAtIndex:[NSNumber numberWithInteger:[tables indexOfObject:[spfSession objectForKey:@"table"]]]];
// Restore table selection indexes
- if([spfSession objectForKey:@"contentSelectedIndexSet"]) {
- NSMutableIndexSet *anIndexSet = [NSMutableIndexSet indexSet];
- NSArray *items = [spfSession objectForKey:@"contentSelectedIndexSet"];
- NSUInteger i;
- for(i=0; i<[items count]; i++)
- [anIndexSet addIndex:[NSArrayObjectAtIndex(items, i) integerValue]];
-
- [tableContentInstance setSelectedRowIndexesToRestore:anIndexSet];
+ if([spfSession objectForKey:@"contentSelection"]) {
+ [tableContentInstance setSelectionToRestore:[spfSession objectForKey:@"contentSelection"]];
}
[[tablesListInstance valueForKeyPath:@"tablesListView"] scrollRowToVisible:[tables indexOfObject:[spfSession objectForKey:@"selectedTable"]]];