From 05ac3cbd9c3eb6559ee1ca6ee7d4ff4e510e6542 Mon Sep 17 00:00:00 2001 From: Bibiko Date: Wed, 26 Jan 2011 22:24:46 +0000 Subject: =?UTF-8?q?=E2=80=A2=20fixed=20table=20list=20querying=20by=20chec?= =?UTF-8?q?king=20utf8=20connection=20since=20we=20query=20info=5Fschema?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Source/SPTableRelations.m | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'Source') diff --git a/Source/SPTableRelations.m b/Source/SPTableRelations.m index b7a4bde6..b65f62fc 100644 --- a/Source/SPTableRelations.m +++ b/Source/SPTableRelations.m @@ -165,22 +165,33 @@ { // Set up the controls [addRelationTableBox setTitle:[NSString stringWithFormat:NSLocalizedString(@"Table: %@", @"Add Relation sheet title, showing table name"), [tablesListInstance tableName]]]; - + [columnPopUpButton removeAllItems]; [columnPopUpButton addItemsWithTitles:[tableDataInstance columnNames]]; - + [refTablePopUpButton removeAllItems]; - + + BOOL changeEncoding = ![[connection encoding] isEqualToString:@"utf8"]; + + // Use UTF8 for identifier-based queries + if (changeEncoding) { + [connection storeEncodingForRestoration]; + [connection setEncoding:@"utf8"]; + } + // Get all InnoDB tables in the current database MCPResult *result = [connection queryString:[NSString stringWithFormat:@"SELECT table_name FROM information_schema.tables WHERE table_type = 'BASE TABLE' AND engine = 'InnoDB' AND table_schema = %@", [[tableDocumentInstance database] tickQuotedString]]]; - + [result dataSeek:0]; - + for (NSInteger i = 0; i < [result numOfRows]; i++) { [refTablePopUpButton addItemWithTitle:[[result fetchRowAsArray] objectAtIndex:0]]; } - + + // Restore encoding if appropriate + if (changeEncoding) [connection restoreStoredEncoding]; + [self selectReferenceTable:nil]; [NSApp beginSheet:addRelationPanel -- cgit v1.2.3