diff options
author | Max <post@wickenrode.com> | 2015-01-02 16:17:22 +0100 |
---|---|---|
committer | Max <post@wickenrode.com> | 2015-01-02 16:17:22 +0100 |
commit | 30ffc7c4d6158e1210b2463dddb62e627ca410db (patch) | |
tree | 436d33198576f1c719aad0060312da3df3eee488 /Source/SPTablesList.m | |
parent | ee588049b5a7f755d788b983dc8cabce24453641 (diff) | |
download | sequelpro-30ffc7c4d6158e1210b2463dddb62e627ca410db.tar.gz sequelpro-30ffc7c4d6158e1210b2463dddb62e627ca410db.tar.bz2 sequelpro-30ffc7c4d6158e1210b2463dddb62e627ca410db.zip |
Some internal addtions for mysql event support
(Also deduplicated some code)
Diffstat (limited to 'Source/SPTablesList.m')
-rw-r--r-- | Source/SPTablesList.m | 41 |
1 files changed, 16 insertions, 25 deletions
diff --git a/Source/SPTablesList.m b/Source/SPTablesList.m index 952d4868..3efc45ef 100644 --- a/Source/SPTablesList.m +++ b/Source/SPTablesList.m @@ -91,6 +91,7 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable"; #endif - (void)_renameTableOfType:(SPTableType)tableType from:(NSString *)oldTableName to:(NSString *)newTableName; - (void)_duplicateConnectionToFrontTab; +- (NSMutableArray *)_allSchemaObjectsOfType:(SPTableType)type; @end @implementation SPTablesList @@ -1286,47 +1287,37 @@ static NSString *SPDuplicateTable = @"SPDuplicateTable"; - (NSArray *)allTableNames { - NSMutableArray *returnArray = [NSMutableArray array]; - NSInteger i; - NSInteger cnt = [[self tables] count]; - for(i=0; i<cnt; i++) { - if([NSArrayObjectAtIndex([self tableTypes],i) integerValue] == SPTableTypeTable) - [returnArray addObject:NSArrayObjectAtIndex([self tables], i)]; - } - return returnArray; + return [self _allSchemaObjectsOfType:SPTableTypeTable]; } - (NSArray *)allViewNames { - NSMutableArray *returnArray = [NSMutableArray array]; - NSInteger i; - NSInteger cnt = [[self tables] count]; - for(i=0; i<cnt; i++) { - if([NSArrayObjectAtIndex([self tableTypes],i) integerValue] == SPTableTypeView) - [returnArray addObject:NSArrayObjectAtIndex([self tables], i)]; - } + NSMutableArray *returnArray = [self _allSchemaObjectsOfType:SPTableTypeView]; [returnArray sortUsingSelector:@selector(compare:)]; return returnArray; } - (NSArray *)allProcedureNames { - NSMutableArray *returnArray = [NSMutableArray array]; - NSInteger i; - NSInteger cnt = [[self tables] count]; - for(i=0; i<cnt; i++) { - if([NSArrayObjectAtIndex([self tableTypes],i) integerValue] == SPTableTypeProc) - [returnArray addObject:NSArrayObjectAtIndex([self tables], i)]; - } - return returnArray; + return [self _allSchemaObjectsOfType:SPTableTypeProc]; } - (NSArray *)allFunctionNames { + return [self _allSchemaObjectsOfType:SPTableTypeFunc]; +} + +- (NSArray *)allEventNames +{ + return [self _allSchemaObjectsOfType:SPTableTypeEvent]; +} + +- (NSMutableArray *)_allSchemaObjectsOfType:(SPTableType)type +{ NSMutableArray *returnArray = [NSMutableArray array]; - NSInteger i; + NSUInteger i; NSInteger cnt = [[self tables] count]; for(i=0; i<cnt; i++) { - if([NSArrayObjectAtIndex([self tableTypes],i) integerValue] == SPTableTypeFunc) + if([NSArrayObjectAtIndex([self tableTypes],i) integerValue] == type) [returnArray addObject:NSArrayObjectAtIndex([self tables], i)]; } return returnArray; |