aboutsummaryrefslogtreecommitdiffstats
path: root/Source/TablesList.m
diff options
context:
space:
mode:
authorrowanbeentje <rowan@beent.je>2009-07-18 20:11:59 +0000
committerrowanbeentje <rowan@beent.je>2009-07-18 20:11:59 +0000
commit00423b8b7175607a05277f21cf16555bd0ee0286 (patch)
tree279fca04d61988da18cc6c10641670cea3f09f9f /Source/TablesList.m
parent1d7e6fcca4ab74d61e0ec9ac21c9f3a49a10c035 (diff)
downloadsequelpro-00423b8b7175607a05277f21cf16555bd0ee0286.tar.gz
sequelpro-00423b8b7175607a05277f21cf16555bd0ee0286.tar.bz2
sequelpro-00423b8b7175607a05277f21cf16555bd0ee0286.zip
- When selecting tables - eg from a foreign key link - fall back to a case insensitive match if a full match fails, as MySQL can return foreign key references as lowercase rather than actual case
Diffstat (limited to 'Source/TablesList.m')
-rw-r--r--Source/TablesList.m11
1 files changed, 10 insertions, 1 deletions
diff --git a/Source/TablesList.m b/Source/TablesList.m
index bba94272..ac0be0d8 100644
--- a/Source/TablesList.m
+++ b/Source/TablesList.m
@@ -1057,7 +1057,9 @@
*/
- (BOOL)selectTableOrViewWithName:(NSString *)theName
{
- int i, tableType, itemIndex = NSNotFound;
+ int i, tableType;
+ int itemIndex = NSNotFound;
+ int caseInsensitiveItemIndex = NSNotFound;
// Loop through the tables/views to find the desired item
for (i = 0; i < [tables count]; i++) {
@@ -1067,8 +1069,15 @@
itemIndex = i;
break;
}
+ if ([[tables objectAtIndex:i] compare:theName options:NSCaseInsensitiveSearch|NSLiteralSearch] == NSOrderedSame)
+ caseInsensitiveItemIndex = i;
}
+ // If no case-sensitive match was found, use a case-insensitive match if available
+ if (itemIndex == NSNotFound && caseInsensitiveItemIndex != NSNotFound)
+ itemIndex = caseInsensitiveItemIndex;
+
+ // If no match found, return failure
if (itemIndex == NSNotFound) return NO;
[tablesListView selectRowIndexes:[NSIndexSet indexSetWithIndex:itemIndex] byExtendingSelection:NO];