diff options
author | rowanbeentje <rowan@beent.je> | 2010-12-05 00:40:09 +0000 |
---|---|---|
committer | rowanbeentje <rowan@beent.je> | 2010-12-05 00:40:09 +0000 |
commit | 5d61e164670c386e73de8903dace40802f00fc00 (patch) | |
tree | aeac970c32bc95ca0db8a6a8671a26d2cdb38bd7 /Source | |
parent | c84d39d22cdc466b6a3d0c0e71966d074789b090 (diff) | |
download | sequelpro-5d61e164670c386e73de8903dace40802f00fc00.tar.gz sequelpro-5d61e164670c386e73de8903dace40802f00fc00.tar.bz2 sequelpro-5d61e164670c386e73de8903dace40802f00fc00.zip |
Apply a tweaked version of a patch by Aaron Linville (http://www.linville.org/) to handle table linking in .dot exports on case-insensitive servers:
- Adds a new checkbox on the .dot export interface controlling the case sensitivty of link handling
- Improve .dot export to use lowercase link references when the option is enabled, fixing .dot exports of table relations of table names with uppercase characters on case-insensitive servers
- Check the server's case-sensitivity setting and use that to control the checkbox when using the export interface to select .dot export
This addresses Issue #920.
Diffstat (limited to 'Source')
-rw-r--r-- | Source/SPDotExporter.h | 11 | ||||
-rw-r--r-- | Source/SPDotExporter.m | 6 | ||||
-rw-r--r-- | Source/SPExportController.h | 8 | ||||
-rw-r--r-- | Source/SPExportController.m | 18 | ||||
-rw-r--r-- | Source/SPExportInitializer.m | 1 |
5 files changed, 38 insertions, 6 deletions
diff --git a/Source/SPDotExporter.h b/Source/SPDotExporter.h index 5de22927..4a962c7b 100644 --- a/Source/SPDotExporter.h +++ b/Source/SPDotExporter.h @@ -42,9 +42,11 @@ NSArray *dotExportTables; NSString *dotExportCurrentTable; - + + BOOL dotForceLowerTableNames; + SPTableData *dotTableData; - + NSString *dotDatabaseHost; NSString *dotDatabaseName; NSString *dotDatabaseVersion; @@ -66,6 +68,11 @@ @property(readwrite, retain) NSString *dotExportCurrentTable; /** + * @property dotForceLowerTableNames dotForceLowerTableNames Force lowercase table names + */ +@property(readwrite, assign) BOOL dotForceLowerTableNames; + +/** * @property dotTableData Table data */ @property(readwrite, retain) SPTableData *dotTableData; diff --git a/Source/SPDotExporter.m b/Source/SPDotExporter.m index 85b497e9..55ab645b 100644 --- a/Source/SPDotExporter.m +++ b/Source/SPDotExporter.m @@ -33,6 +33,7 @@ @synthesize delegate; @synthesize dotExportTables; @synthesize dotExportCurrentTable; +@synthesize dotForceLowerTableNames; @synthesize dotTableData; @synthesize dotDatabaseHost; @synthesize dotDatabaseName; @@ -115,6 +116,7 @@ } NSString *tableName = NSArrayObjectAtIndex([self dotExportTables], i); + NSString *tableLinkName = [self dotForceLowerTableNames]?[tableName lowercaseString]:tableName; NSDictionary *tableInfo = [[self dotTableData] informationForTable:tableName]; // Set the current table @@ -131,7 +133,7 @@ [metaString setString:[NSString stringWithFormat:@"\tsubgraph \"table_%@\" {\n", tableName]]; [metaString appendString:@"\t\tnode [ shape = \"plaintext\" ];\n"]; - [metaString appendFormat:@"\t\t\"%@\" [ label=<\n", tableName]; + [metaString appendFormat:@"\t\t\"%@\" [ label=<\n", tableLinkName]; [metaString appendString:@"\t\t\t<TABLE BORDER=\"0\" CELLSPACING=\"0\" CELLBORDER=\"1\">\n"]; [metaString appendFormat:@"\t\t\t<TR><TD COLSPAN=\"3\" BGCOLOR=\"%@\">%@</TD></TR>\n", hdrColor, tableName]; @@ -173,7 +175,7 @@ extra = @" [ arrowhead=crow, arrowtail=odiamond ]"; } - [fkInfo addObject:[NSString stringWithFormat:@"%@:%@ -> %@:%@ %@", tableName, [originColumns objectAtIndex:0], [aConstraint objectForKey:@"ref_table"], [referenceColumns objectAtIndex:0], extra]]; + [fkInfo addObject:[NSString stringWithFormat:@"%@:%@ -> %@:%@ %@", tableLinkName, [originColumns objectAtIndex:0], [aConstraint objectForKey:@"ref_table"], [[referenceColumns objectAtIndex:0] lowercaseString], extra]]; } } diff --git a/Source/SPExportController.h b/Source/SPExportController.h index 24c30b39..ff5c65ba 100644 --- a/Source/SPExportController.h +++ b/Source/SPExportController.h @@ -108,6 +108,9 @@ IBOutlet NSButton *exportXMLIncludeStructure; IBOutlet NSButton *exportXMLIncludeContent; IBOutlet NSTextField *exportXMLNULLValuesAsTextField; + + // Dot + IBOutlet NSButton *exportDotForceLowerTableNamesCheck; /** * Cancellation flag @@ -204,6 +207,11 @@ */ BOOL sqlPreviousConnectionEncodingViaLatin1; + /** + * The server's lower_case_table_names setting + */ + NSInteger serverLowerCaseTableNameValue; + NSInteger heightOffset1; NSInteger heightOffset2; NSUInteger windowMinWidth; diff --git a/Source/SPExportController.m b/Source/SPExportController.m index 755a4f74..1d70f88f 100644 --- a/Source/SPExportController.m +++ b/Source/SPExportController.m @@ -93,7 +93,8 @@ static const NSString *SPTableViewDropColumnID = @"drop"; showAdvancedView = NO; showCustomFilenameView = NO; - + serverLowerCaseTableNameValue = NSNotFound; + heightOffset1 = 0; heightOffset2 = 0; windowMinWidth = [[self window] minSize].width; @@ -706,10 +707,23 @@ static const NSString *SPTableViewDropColumnID = @"drop"; // Set the tooltip [[exportTableList tableColumnWithIdentifier:SPTableViewContentColumnID] setHeaderToolTip:(enable) ? @"" : NSLocalizedString(@"Include content", @"include content table column tooltip")]; + // When switching to Dot export, ensure the server's lower_case_table_names value is checked the first time + // to set the export's link case sensitivity setting + if (isDot && serverLowerCaseTableNameValue == NSNotFound) { + MCPResult *caseResult = [connection queryString:@"SHOW VARIABLES LIKE 'lower_case_table_names'"]; + [caseResult setReturnDataAsStrings:YES]; + if ([caseResult numOfRows] == 1) { + serverLowerCaseTableNameValue = [[[caseResult fetchRowAsDictionary] objectForKey:@"Value"] integerValue]; + } else { + serverLowerCaseTableNameValue = 0; + } + [exportDotForceLowerTableNamesCheck setState:(serverLowerCaseTableNameValue == 0)?NSOffState:NSOnState]; + } + [exportCSVNULLValuesAsTextField setStringValue:[prefs stringForKey:SPNullValue]]; [exportXMLNULLValuesAsTextField setStringValue:[prefs stringForKey:SPNullValue]]; - [self _displayExportTypeOptions:(isSQL || isCSV || isXML)]; + [self _displayExportTypeOptions:(isSQL || isCSV || isXML || isDot)]; [self updateAvailableExportFilenameTokens]; if (!showCustomFilenameView) [self updateDisplayedExportFilename]; diff --git a/Source/SPExportInitializer.m b/Source/SPExportInitializer.m index 9544bf4b..db951b5f 100644 --- a/Source/SPExportInitializer.m +++ b/Source/SPExportInitializer.m @@ -353,6 +353,7 @@ SPDotExporter *dotExporter = [[SPDotExporter alloc] initWithDelegate:self]; [dotExporter setDotTableData:tableDataInstance]; + [dotExporter setDotForceLowerTableNames:[exportDotForceLowerTableNamesCheck state]]; [dotExporter setDotDatabaseHost:[tableDocumentInstance host]]; [dotExporter setDotDatabaseName:[tableDocumentInstance database]]; [dotExporter setDotDatabaseVersion:[tableDocumentInstance mySQLVersion]]; |