diff options
author | Bibiko <bibiko@eva.mpg.de> | 2010-11-04 17:03:12 +0000 |
---|---|---|
committer | Bibiko <bibiko@eva.mpg.de> | 2010-11-04 17:03:12 +0000 |
commit | 65670f060759c2d5f096db401390da47b9365706 (patch) | |
tree | 4c34858715090715eb49e3ba50a9b93034430a75 /Source/SPNavigatorController.m | |
parent | 286d4ef211a7ab3e9564bbe6a099021e0064c941 (diff) | |
download | sequelpro-65670f060759c2d5f096db401390da47b9365706.tar.gz sequelpro-65670f060759c2d5f096db401390da47b9365706.tar.bz2 sequelpro-65670f060759c2d5f096db401390da47b9365706.zip |
• alias (auto-)completion
- further improvements to match table names
Diffstat (limited to 'Source/SPNavigatorController.m')
-rw-r--r-- | Source/SPNavigatorController.m | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/Source/SPNavigatorController.m b/Source/SPNavigatorController.m index 58141936..aeb5af8c 100644 --- a/Source/SPNavigatorController.m +++ b/Source/SPNavigatorController.m @@ -508,13 +508,23 @@ static NSComparisonResult compareStrings(NSString *s1, NSString *s2, void* conte * Otherwise it return 0. Mainly used for completion to know whether a `foo`. can only be * a db name or a table name. */ -- (NSArray *)getUniqueDbIdentifierFor:(NSString*)term andConnection:(NSString*)connectionID +- (NSArray *)getUniqueDbIdentifierFor:(NSString*)term andConnection:(NSString*)connectionID ignoreFields:(BOOL)ignoreFields { NSString *SPUniqueSchemaDelimiter = @""; NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SELF ENDSWITH[c] %@", [NSString stringWithFormat:@"%@%@", SPUniqueSchemaDelimiter, [term lowercaseString]]]; - NSArray *result = [[allSchemaKeys objectForKey:connectionID] filteredArrayUsingPredicate:predicate]; + NSMutableArray *result = [NSMutableArray arrayWithCapacity:5]; + + NSString *re = [NSString stringWithFormat:@"%@.*?%@.*?%@", SPUniqueSchemaDelimiter, SPUniqueSchemaDelimiter, SPUniqueSchemaDelimiter]; + for(id r in [[allSchemaKeys objectForKey:connectionID] filteredArrayUsingPredicate:predicate]) { + if(ignoreFields) { + if(![r isMatchedByRegex:re]) + [result addObject:r]; + } else { + [result addObject:r]; + } + } if([result count] < 1 ) return [NSArray arrayWithObjects:[NSNumber numberWithInt:0], @"", nil]; if([result count] == 1) { |