aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPTextView.m
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2010-11-04 18:59:46 +0000
committerBibiko <bibiko@eva.mpg.de>2010-11-04 18:59:46 +0000
commitbf083baf5c0e6048b692656cf35fd94d7c652c60 (patch)
treefee6bd50109eb674dc800d9de06caf97de6fe41a /Source/SPTextView.m
parent8f8694d3dec218bf85cc0f36eb6bc90b72ce9c6e (diff)
downloadsequelpro-bf083baf5c0e6048b692656cf35fd94d7c652c60.tar.gz
sequelpro-bf083baf5c0e6048b692656cf35fd94d7c652c60.tar.bz2
sequelpro-bf083baf5c0e6048b692656cf35fd94d7c652c60.zip
• improved completion regarding leading commas
• alias (auto-)completion - further improvements regarding detecting of aliases esp. if used just after SELECT in conjunction with commas
Diffstat (limited to 'Source/SPTextView.m')
-rw-r--r--Source/SPTextView.m17
1 files changed, 9 insertions, 8 deletions
diff --git a/Source/SPTextView.m b/Source/SPTextView.m
index e9fe24a2..570353f2 100644
--- a/Source/SPTextView.m
+++ b/Source/SPTextView.m
@@ -658,7 +658,7 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse)
while(start > 0 && doParsing) {
currentCharacter = [[self string] characterAtIndex:--start];
- if(!(backticksCounter%2) && [whiteSpaceCharSet characterIsMember:currentCharacter]) {
+ if(!(backticksCounter%2) && ([whiteSpaceCharSet characterIsMember:currentCharacter] || currentCharacter == ',')) {
start++;
break;
}
@@ -776,21 +776,22 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse)
// Check if found table name is known, if not parse for aliases
if(![allTables containsObject:[NSString stringWithFormat:@"%@%@%@", conID, SPUniqueSchemaDelimiter, tableName]]) {
NSString *currentQuery = [[self string] substringWithRange:[customQueryInstance currentQueryRange]];
- NSArray *matches = [currentQuery componentsMatchedByRegex:[NSString stringWithFormat:@"(?i)\\s`?(\\S+?)`?\\s+(AS\\s+)?`?%@`?\\b", tableName]];
+ NSString *re = [NSString stringWithFormat:@"(?i)[\\s,]`?(\\S+?)`?\\s+(AS\\s+)?`?%@`?\\b", tableName];
+ NSArray *matches = [currentQuery componentsMatchedByRegex:re];
for(NSString* m in matches) {
- NSRange aliasRange = [m rangeOfRegex:[NSString stringWithFormat:@"(?i)\\s`?(\\S+?)`?\\s+(AS\\s+)?`?%@`?\\b", tableName] capture:1L];
+ NSRange aliasRange = [m rangeOfRegex:re capture:1L];
if(aliasRange.length) {
NSString *alias = [[m substringWithRange:aliasRange] stringByReplacingOccurrencesOfString:@"``" withString:@"`"];
- // If alias refers to db.table split it
+ // If alias refers to db.table split and check it
if([alias rangeOfString:@"."].length) {
NSRange dbRange = [alias rangeOfRegex:@"^`?(.*?)`?\\." capture:1L];
NSRange tbRange = [alias rangeOfRegex:@"\\.`?(.*?)`?$" capture:1L];
NSString *db = [[alias substringWithRange:dbRange] stringByReplacingOccurrencesOfString:@"``" withString:@"`"];
NSString *tb = [[alias substringWithRange:tbRange] stringByReplacingOccurrencesOfString:@"``" withString:@"`"];
- conID = [NSString stringWithFormat:@"%@%@%@", connectionID, SPUniqueSchemaDelimiter, db];
- if([dbs objectForKey:conID] && [[dbs objectForKey:conID] isKindOfClass:[NSDictionary class]]) {
- allTables = [[dbs objectForKey:conID] allKeys];
- if([allTables containsObject:[NSString stringWithFormat:@"%@%@%@", conID, SPUniqueSchemaDelimiter, tb]]) {
+ NSString *curConID = [NSString stringWithFormat:@"%@%@%@", connectionID, SPUniqueSchemaDelimiter, db];
+ if([dbs objectForKey:curConID] && [[dbs objectForKey:curConID] isKindOfClass:[NSDictionary class]]) {
+ allTables = [[dbs objectForKey:curConID] allKeys];
+ if([allTables containsObject:[NSString stringWithFormat:@"%@%@%@", curConID, SPUniqueSchemaDelimiter, tb]]) {
tableName = tb;
dbName = db;
break;