From ce340132e43b5f0d90286704d1232f77f6ffbc8a Mon Sep 17 00:00:00 2001 From: rowanbeentje Date: Thu, 21 Jan 2010 00:45:34 +0000 Subject: - Correctly escape field names when creating foreign keys, and escape the database name when looking up tables to add to the dropdown. Addresses Issue #537. --- Source/SPTableRelations.m | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Source/SPTableRelations.m b/Source/SPTableRelations.m index ee72fd3a..acb5c29c 100644 --- a/Source/SPTableRelations.m +++ b/Source/SPTableRelations.m @@ -115,9 +115,9 @@ NSString *query = [NSString stringWithFormat:@"ALTER TABLE %@ ADD FOREIGN KEY (%@) REFERENCES %@ (%@)", [thisTable backtickQuotedString], - thisColumn, + [thisColumn backtickQuotedString], [thatTable backtickQuotedString], - thatColumn]; + [thatColumn backtickQuotedString]]; // If required add ON DELETE if ([onDeletePopUpButton indexOfSelectedItem] > 0) { @@ -176,7 +176,7 @@ [refTablePopUpButton removeAllItems]; // 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]]]; + 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]; -- cgit v1.2.3