aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPTableData.m
diff options
context:
space:
mode:
authorstuconnolly <stuart02@gmail.com>2013-10-21 14:43:10 +0000
committerstuconnolly <stuart02@gmail.com>2013-10-21 14:43:10 +0000
commit546f436290721d208381769bef646a8ab9d42212 (patch)
tree6c49bf30c7c0328c6f8ff8a42ef6d06f132a4e52 /Source/SPTableData.m
parent43271f8e86b54c7d953c0e1c4059a2530693eb39 (diff)
downloadsequelpro-546f436290721d208381769bef646a8ab9d42212.tar.gz
sequelpro-546f436290721d208381769bef646a8ab9d42212.tar.bz2
sequelpro-546f436290721d208381769bef646a8ab9d42212.zip
Issue #1369: Fix the display of cross database relations.
Diffstat (limited to 'Source/SPTableData.m')
-rw-r--r--Source/SPTableData.m14
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:@","];