From: Neil T. <nt...@us...> - 2006-08-19 12:06:52
|
Update of /cvsroot/pgsqlformac/pgCocoaDB In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10405 Modified Files: ChangeLog ExplorerModel.m Schema.h Schema.m Log Message: Add display of index column names. Index: Schema.m =================================================================== RCS file: /cvsroot/pgsqlformac/pgCocoaDB/Schema.m,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** Schema.m 12 Aug 2006 16:38:16 -0000 1.17 --- Schema.m 19 Aug 2006 12:06:48 -0000 1.18 *************** *** 286,289 **** --- 286,313 ---- } + //select indexname from pg_indexes where schemaname = 'public' AND tablename = 'file_monitor_names'; + //SELECT attname FROM pg_catalog.pg_attribute, pg_catalog.pg_class + //where pg_attribute.attrelid = pg_class.oid + //AND relname LIKE 'file_monitor_names_file_set_name_key'; + + -(RecordSet *)getIndexColumnNamesFromSchema:(NSString *)schemaName fromTableName:(NSString *)tableName fromIndexName:(NSString *)indexName + { + NSString *sql; + sql = [NSString stringWithFormat:@"SELECT attname \ + FROM pg_index x \ + JOIN pg_class c ON c.oid = x.indrelid \ + JOIN pg_class i ON i.oid = x.indexrelid \ + JOIN pg_attribute a ON a. attrelid = i.oid \ + JOIN pg_namespace n ON n.oid = c.relnamespace \ + WHERE c.relkind = 'r'::\"char\" AND i.relkind = 'i'::\"char\" \ + AND c.relname = '%@' \ + AND n.nspname = '%@' \ + AND i.relname = '%@'", tableName, schemaName, indexName]; + #if PGCOCOA_LOG_SQL + NSLog(sql); + #endif + + return [connection execQueryNoLog:sql]; + } -(RecordSet *)getTableColumnNamesFromSchema:(NSString *)schemaName fromTableName:(NSString *) tableName; Index: ChangeLog =================================================================== RCS file: /cvsroot/pgsqlformac/pgCocoaDB/ChangeLog,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** ChangeLog 13 Aug 2006 23:50:24 -0000 1.15 --- ChangeLog 19 Aug 2006 12:06:48 -0000 1.16 *************** *** 1,2 **** --- 1,8 ---- + 2006-08-13 18:50 ntiffin + + * ChangeLog, ExplorerModel.h, ExplorerModel.m, + UnitTest/pgCocoaDBSchemaTest.m: Explorer API change to accomodate + preferences. + 2006-08-12 11:38 ntiffin Index: ExplorerModel.m =================================================================== RCS file: /cvsroot/pgsqlformac/pgCocoaDB/ExplorerModel.m,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** ExplorerModel.m 13 Aug 2006 23:50:24 -0000 1.10 --- ExplorerModel.m 19 Aug 2006 12:06:48 -0000 1.11 *************** *** 209,212 **** --- 209,235 ---- + - (void)createIndexColumnNodes:(ExplorerNode *)aParent fromSchemaName:(NSString *)schemaName fromTableName:(NSString *)tableName fromIndexName:(NSString *)indexName + { + RecordSet * results; + ExplorerNode * newNode; + NSString * colName; + int i; + + results = [schema getIndexColumnNamesFromSchema:schemaName fromTableName:tableName fromIndexName:indexName]; + for (i = 0; i < [results count]; i++) + { + newNode = [[ExplorerNode alloc] init]; + colName = [[[[results itemAtIndex: i] fields] itemAtIndex:0] value]; + [newNode setName:colName]; + [newNode setExplorerType:@"Index Column"]; + [newNode setParent:aParent]; + [newNode setBaseTable:tableName]; + [newNode setBaseSchema:schemaName]; + [aParent addChild:newNode]; + + [newNode release]; + } + } + - (void)createIndexNodes:(ExplorerNode *)aParent fromSchemaName:(NSString *)schemaName fromTableName:(NSString *)tableName { *************** *** 234,240 **** [newNode setBaseTable:tableName]; [newNode setBaseSchema:schemaName]; ! //[newNode setDisplayColumn2:[schema getIndexSQLFromSchema:schemaName fromTableName:tableName fromIndexName:indexName]]; [titleNode addChild:newNode]; [newNode release]; } --- 257,265 ---- [newNode setBaseTable:tableName]; [newNode setBaseSchema:schemaName]; ! // TODO this should only display column names. ! [newNode setDisplayColumn2:[schema getIndexSQLFromSchema:schemaName fromTableName:tableName fromIndexName:indexName]]; [titleNode addChild:newNode]; + [self createIndexColumnNodes:newNode fromSchemaName:schemaName fromTableName:tableName fromIndexName:indexName]; [newNode release]; } Index: Schema.h =================================================================== RCS file: /cvsroot/pgsqlformac/pgCocoaDB/Schema.h,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** Schema.h 16 Jul 2006 23:13:06 -0000 1.10 --- Schema.h 19 Aug 2006 12:06:48 -0000 1.11 *************** *** 41,44 **** --- 41,45 ---- -(RecordSet *)getFunctionNamesFromSchema:(NSString *)schemaName; -(RecordSet *)getIndexNamesFromSchema:(NSString *)schemaName fromTableName:(NSString *) tableName; + -(RecordSet *)getIndexColumnNamesFromSchema:(NSString *)schemaName fromTableName:(NSString *)tableName fromIndexName:(NSString *)indexName; -(RecordSet *)getSchemaNames; -(RecordSet *)getSequenceColumnNamesFromSchema:(NSString *)schemaName fromSequence:(NSString *)sequenceName; |