diff options
Diffstat (limited to 'Source/SPTableData.m')
-rw-r--r-- | Source/SPTableData.m | 14 |
1 files changed, 12 insertions, 2 deletions
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:@","]; |