From 546f436290721d208381769bef646a8ab9d42212 Mon Sep 17 00:00:00 2001 From: stuconnolly Date: Mon, 21 Oct 2013 14:43:10 +0000 Subject: Issue #1369: Fix the display of cross database relations. --- Source/SPTableData.m | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'Source/SPTableData.m') diff --git a/Source/SPTableData.m b/Source/SPTableData.m index 03ce039e..ac11c571 100644 --- a/Source/SPTableData.m +++ b/Source/SPTableData.m @@ -642,8 +642,18 @@ [constraintDetails setObject:keyColumns forKey:@"columns"]; - [fieldsParser setString:[[parts objectAtIndex:6] stringByTrimmingCharactersInSet:bracketSet]]; - [constraintDetails setObject:[fieldsParser unquotedString] forKey:@"ref_table"]; + NSString *part = [[parts objectAtIndex:6] stringByTrimmingCharactersInSet:bracketSet]; + + NSArray *reference = [part captureComponentsMatchedByRegex:@"^`([\\w_.]+)`\\.`([\\w_.]+)`$" options:RKLCaseless range:NSMakeRange(0, [part length]) error:nil]; + + if ([reference count]) { + [constraintDetails setObject:[reference objectAtIndex:1] forKey:@"ref_database"]; + [constraintDetails setObject:[reference objectAtIndex:2] forKey:@"ref_table"]; + } + else { + [fieldsParser setString:part]; + [constraintDetails setObject:[fieldsParser unquotedString] forKey:@"ref_table"]; + } NSMutableArray *refKeyColumns = [NSMutableArray array]; NSArray *refKeyColumnStrings = [[[parts objectAtIndex:7] stringByTrimmingCharactersInSet:bracketSet] componentsSeparatedByString:@","]; -- cgit v1.2.3