From: Neil T. <nt...@us...> - 2006-08-18 17:46:09
|
Update of /cvsroot/pgsqlformac/QueryTool In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31926 Modified Files: ChangeLog MyOutlineView.m SqlDocument.h SqlDocument.m Log Message: Add missing SQL formation routines. Index: SqlDocument.m =================================================================== RCS file: /cvsroot/pgsqlformac/QueryTool/SqlDocument.m,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** SqlDocument.m 13 Aug 2006 23:54:30 -0000 1.18 --- SqlDocument.m 18 Aug 2006 17:46:01 -0000 1.19 *************** *** 712,716 **** NSAssert(tableName,@"onSelectCreateUniqIndexOnColsMenuItem: no table name."); NSAssert(schemaName, @"onSelectCreateUniqIndexOnColsMenuItem: no schema name."); ! bool first = true; int indexCount = [[explorer schema] getIndexCountFromSchema:schemaName fromTableName:tableName] + 1; --- 712,716 ---- NSAssert(tableName,@"onSelectCreateUniqIndexOnColsMenuItem: no table name."); NSAssert(schemaName, @"onSelectCreateUniqIndexOnColsMenuItem: no schema name."); ! BOOL first = true; int indexCount = [[explorer schema] getIndexCountFromSchema:schemaName fromTableName:tableName] + 1; *************** *** 730,735 **** --- 730,765 ---- } + // ALTER TABLE distributors + // ALTER COLUMN address TYPE varchar(80), + // ALTER COLUMN name TYPE varchar(100); + - (void)onSelectAlterTabAlterColMenuItem:(id)sender + { + BOOL first = true; + NSIndexSet *theRows =[schemaView selectedRowIndexes]; + unsigned int currentRow =[theRows firstIndex]; + NSString *tableName = [[schemaView itemAtRow:currentRow] baseTable]; + NSString *schemaName = [[schemaView itemAtRow:currentRow] baseSchema]; + NSAssert(tableName,@"onSelectCreateViewMenuItem: no table name."); + NSAssert(schemaName, @"onSelectCreateViewMenuItem: no schema name."); + + NSMutableString *sql = [[[NSMutableString alloc] init] autorelease]; + [sql appendFormat:@"ALTER TABLE %@.%@\n", schemaName, tableName]; + while (currentRow != NSNotFound) { + if (!first) + { + [sql appendString:@", \n"]; + } + [sql appendFormat:@" ALTER COLUMN %@ TYPE %@", [[schemaView itemAtRow:currentRow] name], [[schemaView itemAtRow:currentRow] displayColumn2]]; + currentRow = [theRows indexGreaterThanIndex: currentRow]; + first = false; + } + [sql appendString:@";\n"]; + [query insertText:sql]; + } + + //ALTER TABLE distributors ADD COLUMN address varchar(30); - (void)onSelectAlterAddColMenuItem:(id)sender { + BOOL first = true; NSIndexSet *theRows =[schemaView selectedRowIndexes]; unsigned int currentRow =[theRows firstIndex]; *************** *** 739,748 **** NSAssert(schemaName, @"onSelectCreateViewMenuItem: no schema name."); ! NSString *sql = [NSString stringWithFormat:@"TODO %@ %@\n", schemaName, tableName]; [query insertText:sql]; } - (void)onSelectAlterRenameColMenuItem:(id)sender { NSIndexSet *theRows =[schemaView selectedRowIndexes]; unsigned int currentRow =[theRows firstIndex]; --- 769,791 ---- NSAssert(schemaName, @"onSelectCreateViewMenuItem: no schema name."); ! NSMutableString *sql = [[[NSMutableString alloc] init] autorelease]; ! [sql appendFormat:@"ALTER TABLE %@.%@\n", schemaName, tableName]; ! while (currentRow != NSNotFound) { ! if (!first) ! { ! [sql appendString:@", \n"]; ! } ! [sql appendFormat:@" ADD COLUMN %@ %@", [[schemaView itemAtRow:currentRow] name], [[schemaView itemAtRow:currentRow] displayColumn2]]; ! currentRow = [theRows indexGreaterThanIndex: currentRow]; ! first = false; ! } ! [sql appendString:@";\n"]; [query insertText:sql]; } + //ALTER TABLE distributors RENAME COLUMN address TO city; - (void)onSelectAlterRenameColMenuItem:(id)sender { + BOOL first = true; NSIndexSet *theRows =[schemaView selectedRowIndexes]; unsigned int currentRow =[theRows firstIndex]; *************** *** 752,756 **** NSAssert(schemaName, @"onSelectCreateViewMenuItem: no schema name."); ! NSString *sql = [NSString stringWithFormat:@"TODO %@ %@\n", schemaName, tableName]; [query insertText:sql]; } --- 795,810 ---- NSAssert(schemaName, @"onSelectCreateViewMenuItem: no schema name."); ! NSMutableString *sql = [[[NSMutableString alloc] init] autorelease]; ! [sql appendFormat:@"ALTER TABLE %@.%@\n", schemaName, tableName]; ! while (currentRow != NSNotFound) { ! if (!first) ! { ! [sql appendString:@", \n"]; ! } ! [sql appendFormat:@" RENAME COLUMN %@ TO <New Name>", [[schemaView itemAtRow:currentRow] name]]; ! currentRow = [theRows indexGreaterThanIndex: currentRow]; ! first = false; ! } ! [sql appendString:@";\n"]; [query insertText:sql]; } *************** *** 785,788 **** --- 839,843 ---- - (void)onSelectDropColMenuItem:(id)sender { + BOOL first = true; NSIndexSet *theRows =[schemaView selectedRowIndexes]; unsigned int currentRow =[theRows firstIndex]; *************** *** 792,796 **** NSAssert(schemaName, @"onSelectCreateViewMenuItem: no schema name."); ! NSString *sql = [NSString stringWithFormat:@"TODO %@ %@\n", schemaName, tableName]; [query insertText:sql]; } --- 847,862 ---- NSAssert(schemaName, @"onSelectCreateViewMenuItem: no schema name."); ! NSMutableString *sql = [[[NSMutableString alloc] init] autorelease]; ! [sql appendFormat:@"ALTER TABLE %@.%@\n", schemaName, tableName]; ! while (currentRow != NSNotFound) { ! if (!first) ! { ! [sql appendString:@", \n"]; ! } ! [sql appendFormat:@" DROP COLUMN %@", [[schemaView itemAtRow:currentRow] name]]; ! currentRow = [theRows indexGreaterThanIndex: currentRow]; ! first = false; ! } ! [sql appendString:@";\n"]; [query insertText:sql]; } Index: ChangeLog =================================================================== RCS file: /cvsroot/pgsqlformac/QueryTool/ChangeLog,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** ChangeLog 13 Aug 2006 23:54:30 -0000 1.12 --- ChangeLog 18 Aug 2006 17:46:01 -0000 1.13 *************** *** 1,2 **** --- 1,7 ---- + 2006-08-13 18:54 ntiffin + + * ChangeLog, SqlDocument.m, TODO.txt: Fix bug associated with + releaseing explorer too early. + 2006-08-12 11:39 ntiffin Index: MyOutlineView.m =================================================================== RCS file: /cvsroot/pgsqlformac/QueryTool/MyOutlineView.m,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** MyOutlineView.m 16 Jul 2006 23:17:39 -0000 1.6 --- MyOutlineView.m 18 Aug 2006 17:46:01 -0000 1.7 *************** *** 98,101 **** --- 98,107 ---- newItem = [[NSMenuItem alloc] init]; + [newItem setTitle:@"ALTER TABLE <tab> ALTER COLUMN <col> TYPE <type>"]; + [newItem setTarget: menuActionTarget]; + [newItem setAction: @selector(onSelectAlterTabAlterColMenuItem:)]; + [columnMenu addItem: newItem]; + + newItem = [[NSMenuItem alloc] init]; [newItem setTitle:@"ALTER TABLE <tab> ADD COLUMN <col> <type>"]; [newItem setTarget: menuActionTarget]; Index: SqlDocument.h =================================================================== RCS file: /cvsroot/pgsqlformac/QueryTool/SqlDocument.h,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** SqlDocument.h 16 Jul 2006 23:17:39 -0000 1.11 --- SqlDocument.h 18 Aug 2006 17:46:01 -0000 1.12 *************** *** 101,104 **** --- 101,105 ---- - (void)onSelectCreateTabColsMenuItem:(id)sender; - (void)onSelectDropColMenuItem:(id)sender; + - (void)onSelectAlterTabAlterColMenuItem:(id)sender; // Views |