diff options
author | stuconnolly <stuart02@gmail.com> | 2009-05-27 13:30:34 +0000 |
---|---|---|
committer | stuconnolly <stuart02@gmail.com> | 2009-05-27 13:30:34 +0000 |
commit | 4cb9f0b6ab99875d487ae9c2c438595978222a3e (patch) | |
tree | be63b305825ba346a73f5bb267bd7113150b61a2 /Source/SPTableData.m | |
parent | de6f4edd315c319bd7fbc37907176d665aa454dc (diff) | |
download | sequelpro-4cb9f0b6ab99875d487ae9c2c438595978222a3e.tar.gz sequelpro-4cb9f0b6ab99875d487ae9c2c438595978222a3e.tar.bz2 sequelpro-4cb9f0b6ab99875d487ae9c2c438595978222a3e.zip |
Redesigned table information pane.
Diffstat (limited to 'Source/SPTableData.m')
-rw-r--r-- | Source/SPTableData.m | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/Source/SPTableData.m b/Source/SPTableData.m index 7a989d0c..bedc9dc1 100644 --- a/Source/SPTableData.m +++ b/Source/SPTableData.m @@ -43,7 +43,9 @@ columnNames = [[NSMutableArray alloc] init]; constraints = [[NSMutableArray alloc] init]; status = [[NSMutableDictionary alloc] init]; + tableEncoding = nil; + tableCreateSyntax = nil; mySQLConnection = nil; } @@ -76,6 +78,23 @@ return [NSString stringWithString:tableEncoding]; } +/* + * Retrieve the create syntax for the current table, using or refreshing the cache as appropriate. + */ +- (NSString *) tableCreateSyntax +{ + if (tableCreateSyntax == nil) { + if ([tableListInstance tableType] == SP_TABLETYPE_VIEW) { + [self updateInformationForCurrentView]; + } + else { + [self updateInformationForCurrentTable]; + } + } + + return [NSString stringWithString:tableCreateSyntax]; +} + /* * Retrieve all columns for the current table as an array, using or refreshing the cache as appropriate. @@ -189,10 +208,16 @@ [columns removeAllObjects]; [columnNames removeAllObjects]; [status removeAllObjects]; + if (tableEncoding != nil) { [tableEncoding release]; tableEncoding = nil; } + + if (tableCreateSyntax != nil) { + [tableCreateSyntax release]; + tableCreateSyntax = nil; + } } @@ -272,6 +297,8 @@ [columnNames removeAllObjects]; [constraints removeAllObjects]; + if (tableCreateSyntax != nil) [tableCreateSyntax release]; + // Catch unselected tables and return nil if ([tableName isEqualToString:@""] || !tableName) return nil; @@ -290,9 +317,12 @@ // Retrieve the table syntax string NSArray *syntaxResult = [theResult fetchRowAsArray]; + if ([[syntaxResult objectAtIndex:1] isKindOfClass:[NSData class]]) { + tableCreateSyntax = [[NSString alloc] initWithData:[syntaxResult objectAtIndex:1] encoding:[mySQLConnection encoding]]; createTableParser = [[SPSQLParser alloc] initWithData:[syntaxResult objectAtIndex:1] encoding:[mySQLConnection encoding]]; } else { + tableCreateSyntax = [[NSString alloc] initWithString:[syntaxResult objectAtIndex:1]]; createTableParser = [[SPSQLParser alloc] initWithString:[syntaxResult objectAtIndex:1]]; } @@ -837,7 +867,9 @@ [columnNames release]; [constraints release]; [status release]; + if (tableEncoding != nil) [tableEncoding release]; + if (tableCreateSyntax != nil) [tableCreateSyntax release]; [super dealloc]; } |