From 00423b8b7175607a05277f21cf16555bd0ee0286 Mon Sep 17 00:00:00 2001 From: rowanbeentje Date: Sat, 18 Jul 2009 20:11:59 +0000 Subject: - 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 --- Source/TablesList.m | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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]; -- cgit v1.2.3