diff options
author | rowanbeentje <rowan@beent.je> | 2009-04-06 23:54:25 +0000 |
---|---|---|
committer | rowanbeentje <rowan@beent.je> | 2009-04-06 23:54:25 +0000 |
commit | 6060ba57f5897bffdd35dbca438e6682b2960f75 (patch) | |
tree | 86c9d9e00b88f40c5f4cad36d050c07997f751b6 /Source/TableDocument.m | |
parent | 16aee03a9c48ffdaf33fd3f2c99f7b5a933ca0ee (diff) | |
download | sequelpro-6060ba57f5897bffdd35dbca438e6682b2960f75.tar.gz sequelpro-6060ba57f5897bffdd35dbca438e6682b2960f75.tar.bz2 sequelpro-6060ba57f5897bffdd35dbca438e6682b2960f75.zip |
- Select 'drop tables' option for MySQL export by default, to improve backup-type process and more closely match mysqldump, and correctly drop views
- Consistently set and restore the encoding appropriately for SQL import/export, and export to UTF8 files to correctly store all characters. Goes a good way towards addressing Issue #116.
Diffstat (limited to 'Source/TableDocument.m')
-rw-r--r-- | Source/TableDocument.m | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/Source/TableDocument.m b/Source/TableDocument.m index 72742cf6..15bc444b 100644 --- a/Source/TableDocument.m +++ b/Source/TableDocument.m @@ -635,11 +635,11 @@ NSString *TableDocumentFavoritesControllerFavoritesDidChange = @"TableDocumentFa */ - (void)setConnectionEncoding:(NSString *)mysqlEncoding reloadingViews:(BOOL)reloadViews { - BOOL uselatin1results = NO; + _encodingViaLatin1 = NO; // Special-case UTF-8 over latin 1 to allow viewing/editing of mangled data. if ([mysqlEncoding isEqualToString:@"utf8-"]) { - uselatin1results = YES; + _encodingViaLatin1 = YES; mysqlEncoding = @"utf8"; } @@ -647,13 +647,14 @@ NSString *TableDocumentFavoritesControllerFavoritesDidChange = @"TableDocumentFa [mySQLConnection queryString:[NSString stringWithFormat:@"SET NAMES '%@'", mysqlEncoding]]; if ( [[mySQLConnection getLastErrorMessage] isEqualToString:@""] ) { - if (uselatin1results) + if (_encodingViaLatin1) [mySQLConnection queryString:@"SET CHARACTER_SET_RESULTS=latin1"]; [mySQLConnection setEncoding:[CMMCPConnection encodingForMySQLEncoding:[mysqlEncoding UTF8String]]]; [_encoding autorelease]; _encoding = [mysqlEncoding retain]; } else { [mySQLConnection queryString:[NSString stringWithFormat:@"SET NAMES '%@'", [self databaseEncoding]]]; + _encodingViaLatin1 = NO; if ( ![[mySQLConnection getLastErrorMessage] isEqualToString:@""] ) { NSLog(@"Error: could not set encoding to %@ nor fall back to database encoding on MySQL %@", mysqlEncoding, [self mySQLVersion]); return; @@ -661,7 +662,7 @@ NSString *TableDocumentFavoritesControllerFavoritesDidChange = @"TableDocumentFa } // update the selected menu item - if (uselatin1results) { + if (_encodingViaLatin1) { [self updateEncodingMenuWithSelectedEncoding:[self encodingNameFromMySQLEncoding:[NSString stringWithFormat:@"%@-", mysqlEncoding]]]; } else { [self updateEncodingMenuWithSelectedEncoding:[self encodingNameFromMySQLEncoding:mysqlEncoding]]; @@ -685,6 +686,14 @@ NSString *TableDocumentFavoritesControllerFavoritesDidChange = @"TableDocumentFa } /** + * Returns whether the current encoding should display results via Latin1 transport for backwards compatibility + */ +- (BOOL)connectionEncodingViaLatin1 +{ + return _encodingViaLatin1; +} + +/** * updates the currently selected item in the encoding menu * * @param NSString *encoding - the title of the menu item which will be selected |